diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 4cd08bc03..527e3be18 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -362,6 +362,10 @@ module ApplicationHelper
end
end
+ def noindex
+ content_for(:html_header, tag.meta(name: "robots", content: "noindex"))
+ end
+
def atom_feed_tag(title, url = {})
content_for(:html_header, auto_discovery_link_tag(:atom, url, title: title))
end
diff --git a/app/logical/post_sets/post.rb b/app/logical/post_sets/post.rb
index 9c377581c..6822248fa 100644
--- a/app/logical/post_sets/post.rb
+++ b/app/logical/post_sets/post.rb
@@ -122,6 +122,7 @@ module PostSets
def hide_from_crawler?
return true if current_page > 50
+ return true if artist.present? && artist.is_banned?
return false if query.is_empty_search? || query.is_simple_tag? || query.is_metatag?(:order, :rank)
true
end
diff --git a/app/views/artists/show.html.erb b/app/views/artists/show.html.erb
index 19b92f942..870c3febc 100644
--- a/app/views/artists/show.html.erb
+++ b/app/views/artists/show.html.erb
@@ -1,3 +1,5 @@
+<% noindex if @artist.is_banned? %>
+
<%= render layout: "show" do %>
<%= render "summary", artist: @artist %>
diff --git a/app/views/posts/partials/index/_seo_meta_tags.html.erb b/app/views/posts/partials/index/_seo_meta_tags.html.erb
index cedb48987..66755c3e0 100644
--- a/app/views/posts/partials/index/_seo_meta_tags.html.erb
+++ b/app/views/posts/partials/index/_seo_meta_tags.html.erb
@@ -14,9 +14,7 @@
<% canonical_url root_url(host: Danbooru.config.hostname) %>
<% end %>
-<% if @post_set.hide_from_crawler? %>
-
-<% end %>
+<% noindex if @post_set.hide_from_crawler? %>
<% if @post_set.has_explicit? %>
diff --git a/app/views/wiki_pages/show.html.erb b/app/views/wiki_pages/show.html.erb
index af7285b70..e2cdcf11d 100644
--- a/app/views/wiki_pages/show.html.erb
+++ b/app/views/wiki_pages/show.html.erb
@@ -1,6 +1,10 @@
<% page_title "#{@wiki_page.pretty_title.titleize} Wiki" %>
<% meta_description DText.excerpt(@wiki_page.body) %>
+<% if @wiki_page.artist.present? && @wiki_page.artist.is_banned? %>
+ <% noindex %>
+<% end %>
+
<%= render "secondary_links" %>
<%= render "sidebar" %>
diff --git a/test/functional/artists_controller_test.rb b/test/functional/artists_controller_test.rb
index 352d34a78..f951a335b 100644
--- a/test/functional/artists_controller_test.rb
+++ b/test/functional/artists_controller_test.rb
@@ -65,6 +65,14 @@ class ArtistsControllerTest < ActionDispatch::IntegrationTest
assert_response :success
assert_select ".artist-wiki", count: 0
end
+
+ should "mark banned artists as noindex" do
+ @artist = create(:artist, is_banned: true)
+ get artist_path(@artist.id)
+
+ assert_response :success
+ assert_select "meta[name=robots][content=noindex]"
+ end
end
context "new action" do
diff --git a/test/functional/posts_controller_test.rb b/test/functional/posts_controller_test.rb
index bcae0e069..a1e8fe58a 100644
--- a/test/functional/posts_controller_test.rb
+++ b/test/functional/posts_controller_test.rb
@@ -112,6 +112,16 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
assert_select "#view-artist-link", count: 0
end
+ should "render for a banned artist tag" do
+ artist = create(:artist, is_banned: true)
+ create(:post, tag_string: artist.name)
+ get posts_path, params: { tags: artist.name }
+
+ assert_response :success
+ assert_select "#show-excerpt-link", count: 1, text: "Artist"
+ assert_select "meta[name=robots][content=noindex]"
+ end
+
should "render for a tag with a wiki page" do
create(:post, tag_string: "char:fumimi", rating: "s")
get posts_path, params: { tags: "fumimi" }
diff --git a/test/functional/wiki_pages_controller_test.rb b/test/functional/wiki_pages_controller_test.rb
index 0c8ae20b3..41d378c9a 100644
--- a/test/functional/wiki_pages_controller_test.rb
+++ b/test/functional/wiki_pages_controller_test.rb
@@ -121,6 +121,14 @@ class WikiPagesControllerTest < ActionDispatch::IntegrationTest
get wiki_page_path("....xml")
assert_response :success
end
+
+ should "mark banned artists as noindex" do
+ @artist = create(:artist, name: @wiki_page.title, is_banned: true)
+ get wiki_page_path(@wiki_page.title)
+
+ assert_response :success
+ assert_select "meta[name=robots][content=noindex]"
+ end
end
context "show_or_new action" do