Robots, begone (#1812)

* robots.txt: "Please, don't come in." If a page is directly linked, the
  URL can still appear in search results, though.
* X-Robots-Tag: "If you're here, forget what you saw." Works even if the
  crawler ignores robots.txt or reaches a page via external link. Can
  remove already-indexed pages.
* Public boards may not be indexed. They're meant for "anyone with the
  link" private sharing, not worldwide publishing.
This commit is contained in:
Jeremy Daer
2025-12-02 13:35:58 -08:00
committed by GitHub
parent 72f87f2d8f
commit b755b3fead
4 changed files with 45 additions and 1 deletions
@@ -1,6 +1,7 @@
class ApplicationController < ActionController::Base
include Authentication
include Authorization
include BlockSearchEngineIndexing
include CurrentRequest, CurrentTimezone, SetPlatform
include RequestForgeryProtection
include TurboFlash, ViewTransitions
@@ -0,0 +1,14 @@
# Tell crawlers like Googlebot to drop pages entirely from search results, even
# if other sites link to it
module BlockSearchEngineIndexing
extend ActiveSupport::Concern
included do
after_action :block_search_engine_indexing
end
private
def block_search_engine_indexing
headers["X-Robots-Tag"] = "none"
end
end