mirror of
https://github.com/discourse/discourse.git
synced 2025-01-16 03:52:41 +08:00
DEV: Add a nofollow to /u so user profiles don't get added as a target for crawling (#30693)
In some sites, we are noticing that /u routes are getting indexed. This commit adds a ["nofollow"](https://developers.google.com/search/docs/crawling-indexing/qualify-outbound-links) on user profiles so that Google will not index these user profile URLs.
This commit is contained in:
parent
0caeadd9b1
commit
e8aa2b8d9a
|
@ -15,7 +15,7 @@
|
||||||
<% @about.admins.each do |user| %>
|
<% @about.admins.each do |user| %>
|
||||||
<div itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'>
|
<div itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'>
|
||||||
<meta itemprop='url' content='<%= user_path(user.encoded_username(lower: true)) %>'>
|
<meta itemprop='url' content='<%= user_path(user.encoded_username(lower: true)) %>'>
|
||||||
<a href='<%= user_path(user.encoded_username(lower: true)) %>' itemprop='item'>
|
<a rel='nofollow' href='<%= user_path(user.encoded_username(lower: true)) %>' itemprop='item'>
|
||||||
<span itemprop='image'>
|
<span itemprop='image'>
|
||||||
<img width="45" height="45" class="avatar" src="<%= user.small_avatar_url %>">
|
<img width="45" height="45" class="avatar" src="<%= user.small_avatar_url %>">
|
||||||
</span>
|
</span>
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
<% @about.moderators.each do |user| %>
|
<% @about.moderators.each do |user| %>
|
||||||
<div itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'>
|
<div itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'>
|
||||||
<meta itemprop='url' content='<%= user_path(user.encoded_username(lower: true)) %>'>
|
<meta itemprop='url' content='<%= user_path(user.encoded_username(lower: true)) %>'>
|
||||||
<a href='<%= user_path(user.encoded_username(lower: true)) %>' itemprop='item'>
|
<a rel='nofollow' href='<%= user_path(user.encoded_username(lower: true)) %>' itemprop='item'>
|
||||||
<span itemprop='image'>
|
<span itemprop='image'>
|
||||||
<img width="45" height="45" class="avatar" src="<%= user.small_avatar_url %>">
|
<img width="45" height="45" class="avatar" src="<%= user.small_avatar_url %>">
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%- if SiteSetting.prioritize_username_in_ux %>
|
<%- if SiteSetting.prioritize_username_in_ux %>
|
||||||
<a class="username username-link" href="<%=Discourse.base_url%>/u/<%= post.user.username_lower%>" target="_blank"><%= post.user.username %></a>
|
<a rel='nofollow' class="username username-link" href="<%=Discourse.base_url%>/u/<%= post.user.username_lower%>" target="_blank"><%= post.user.username %></a>
|
||||||
<%- if show_name_on_post(post) %>
|
<%- if show_name_on_post(post) %>
|
||||||
<span class='user-name username-title'><%= post.user.name %></span>
|
<span class='user-name username-title'><%= post.user.name %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%- else %>
|
<%- else %>
|
||||||
<a class="username username-link" href="<%=Discourse.base_url%>/u/<%= post.user.username_lower%>" target="_blank"><%= post.user.name %></a>
|
<a rel='nofollow' class="username username-link" href="<%=Discourse.base_url%>/u/<%= post.user.username_lower%>" target="_blank"><%= post.user.name %></a>
|
||||||
<%- if show_username_on_post(post) %>
|
<%- if show_username_on_post(post) %>
|
||||||
<span class='username username-title'><%= post.user.username %></span>
|
<span class='username username-title'><%= post.user.username %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
<%- end %>
|
<%- end %>
|
||||||
|
|
||||||
<div class='author'>
|
<div class='author'>
|
||||||
<a href='<%= Discourse.base_url %>/u/<%= post.username %>' target="_blank"><img src='<%= post.user.small_avatar_url %>' alt=''></a>
|
<a rel='nofollow' href='<%= Discourse.base_url %>/u/<%= post.username %>' target="_blank"><img src='<%= post.user.small_avatar_url %>' alt=''></a>
|
||||||
</div>
|
</div>
|
||||||
<div class='cooked'>
|
<div class='cooked'>
|
||||||
<h3 class='username'>
|
<h3 class='username'>
|
||||||
<a href='<%= Discourse.base_url %>/u/<%= post.username %>' target="_blank" class='<% if post.user.staff? %>staff<% end %><% if post.user.new_user? %>new-user<% end %>'><%= post.user.username %></a>
|
<a rel='nofollow' href='<%= Discourse.base_url %>/u/<%= post.username %>' target="_blank" class='<% if post.user.staff? %>staff<% end %><% if post.user.new_user? %>new-user<% end %>'><%= post.user.username %></a>
|
||||||
<%- if post.user.title.present? %>
|
<%- if post.user.title.present? %>
|
||||||
<span class='title'><%= post.user.title %></span>
|
<span class='title'><%= post.user.title %></span>
|
||||||
<%- end %>
|
<%- end %>
|
||||||
|
|
|
@ -87,7 +87,7 @@
|
||||||
</td>
|
</td>
|
||||||
<td class='posters'>
|
<td class='posters'>
|
||||||
<% t.posters.each do |poster| %>
|
<% t.posters.each do |poster| %>
|
||||||
<a href="<%= Discourse.base_url %>/u/<%= poster.user.username %>" class="<%= poster.extras %>">
|
<a rel='nofollow' href="<%= Discourse.base_url %>/u/<%= poster.user.username %>" class="<%= poster.extras %>">
|
||||||
<%- poster_name_and_description = h(poster.name_and_description) %>
|
<%- poster_name_and_description = h(poster.name_and_description) %>
|
||||||
<img width="25" height="25" src="<%= poster.user.avatar_template.gsub('{size}', '25') %>" class="avatar" title='<%= poster_name_and_description %>' aria-label='<%= poster_name_and_description %>'>
|
<img width="25" height="25" src="<%= poster.user.avatar_template.gsub('{size}', '25') %>" class="avatar" title='<%= poster_name_and_description %>' aria-label='<%= poster_name_and_description %>'>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
<% if @topic_view.topic.user.present? %>
|
<% if @topic_view.topic.user.present? %>
|
||||||
<span itemprop='author' itemscope itemtype="http://schema.org/Person">
|
<span itemprop='author' itemscope itemtype="http://schema.org/Person">
|
||||||
<meta itemprop='name' content='<%= @topic_view.topic.user.username %>'>
|
<meta itemprop='name' content='<%= @topic_view.topic.user.username %>'>
|
||||||
<link itemprop='url' href='<%= Discourse.base_url %>/u/<%= @topic_view.topic.user.username %>'>
|
<link itemprop='url' rel='nofollow' href='<%= Discourse.base_url %>/u/<%= @topic_view.topic.user.username %>'>
|
||||||
</span>
|
</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
<meta itemprop='text' content='<%= @topic_view.topic.excerpt %>'>
|
<meta itemprop='text' content='<%= @topic_view.topic.excerpt %>'>
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
<div id='post_<%= post.post_number %>' <%= post.is_first_post? ? "" : "itemprop='comment' itemscope itemtype='http://schema.org/Comment'".html_safe %> class='topic-body crawler-post'>
|
<div id='post_<%= post.post_number %>' <%= post.is_first_post? ? "" : "itemprop='comment' itemscope itemtype='http://schema.org/Comment'".html_safe %> class='topic-body crawler-post'>
|
||||||
<div class='crawler-post-meta'>
|
<div class='crawler-post-meta'>
|
||||||
<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" rel='nofollow' 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?) %>
|
||||||
<%
|
<%
|
||||||
post_custom_fields = @topic_view.post_custom_fields[post.id] || {}
|
post_custom_fields = @topic_view.post_custom_fields[post.id] || {}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user