A platform for community discussion. Free, open, simple.
FEATURE: add category name in articleSection meta tag for schema. (#21004)
Vinoth Kannan7cedb911a759
diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erbindex 2df22c41421..5ddec148677 100644--- a/app/views/topics/show.html.erb+++ b/app/views/topics/show.html.erb@@ -36,6 +36,9 @@<%- if include_crawler_content? %><div itemscope itemtype='http://schema.org/DiscussionForumPosting'><meta itemprop='headline' content='<%= @topic_view.title %>'>+ <% if @topic_view.topic.category.present? %>+ <meta itemprop='articleSection' content='<%= @topic_view.topic.category.name %>'>+ <% end %><meta itemprop='keywords' content='<%= @tags.map(&:name).join(', ') %>'><div itemprop='publisher' itemscope itemtype="http://schema.org/Organization"><meta itemprop='name' content='<%= SiteSetting.company_name.presence || SiteSetting.title %>'>diff --git a/spec/views/topics/show.html.erb_spec.rb b/spec/views/topics/show.html.erb_spec.rbindex d4a401b1395..026e58ff965 100644--- a/spec/views/topics/show.html.erb_spec.rb+++ b/spec/views/topics/show.html.erb_spec.rb@@ -59,5 +59,6 @@ RSpec.describe "topics/show.html.erb" dotopic_schema = doc.css('[itemtype="http://schema.org/DiscussionForumPosting"]')expect(topic_schema.size).to eq(1)expect(topic_schema.css('[itemtype="http://schema.org/Comment"]').size).to eq(2)+ expect(topic_schema.css('[itemprop="articleSection"]')[0]["content"]).to eq(topic.category.name)endend