FEATURE: Add structured data to follow Google's guidelines (#9764)

All Schema.org properties are optional, but Google has a set of
properties which are required.
This commit is contained in:
Dan Ungureanu
2020-05-14 10:42:01 +03:00
committed by GitHub
parent d226783405
commit b80128a973

View File

@ -36,9 +36,17 @@
<%- if include_crawler_content? %> <%- if include_crawler_content? %>
<% @topic_view.posts.each_with_index do |post, idx| %> <% @topic_view.posts.each_with_index do |post, idx| %>
<div itemscope itemtype='http://schema.org/DiscussionForumPosting' class='topic-body crawler-post'> <% if (u = post.user) %>
<% if (u = post.user) %> <div itemscope itemtype='http://schema.org/DiscussionForumPosting' class='topic-body crawler-post'>
<div class='crawler-post-meta'> <div class='crawler-post-meta'>
<div itemprop='publisher' itemscope itemtype="http://schema.org/Organization">
<meta itemprop='name' content='<%= SiteSetting.company_name.presence || SiteSetting.title %>'>
<% if application_logo_url.present? %>
<div itemprop='logo' itemscope itemtype="http://schema.org/ImageObject">
<meta itemprop='url' content='<%= application_logo_url %>'>
</div>
<% end %>
</div>
<span class="creator" itemprop="author" itemscope itemtype="http://schema.org/Person"> <span class="creator" itemprop="author" itemscope itemtype="http://schema.org/Person">
<a itemprop="url" href='<%= Discourse.base_url %>/u/<%= u.username %>'><span itemprop='name'><%= u.username %></span></a> <a itemprop="url" href='<%= Discourse.base_url %>/u/<%= u.username %>'><span itemprop='name'><%= u.username %></span></a>
<%= "(#{u.name})" if (SiteSetting.display_name_on_posts && SiteSetting.enable_names? && !u.name.blank?) %> <%= "(#{u.name})" if (SiteSetting.display_name_on_posts && SiteSetting.enable_names? && !u.name.blank?) %>
@ -51,6 +59,8 @@
<% end %> <% end %>
</span> </span>
<link itemprop="mainEntityOfPage" href="<%= post.topic.url %>">
<% if post.image_url %> <% if post.image_url %>
<link itemprop="image" href="<%= Discourse.base_url %><%= post.image_url %>"> <link itemprop="image" href="<%= Discourse.base_url %><%= post.image_url %>">
<% end %> <% end %>
@ -105,9 +115,8 @@
<% end %> <% end %>
</div> </div>
<% end %> <% end %>
</div>
<% end %> <% end %>
</div>
<% end %> <% end %>
<% if @topic_view.prev_page || @topic_view.next_page %> <% if @topic_view.prev_page || @topic_view.next_page %>