From b53d14538ec7e69ec2484e7d23a4ece5eab96c4a Mon Sep 17 00:00:00 2001 From: Simon Hughesdon Date: Tue, 3 Sep 2019 14:08:40 +0100 Subject: [PATCH] Ban indexing in preview apps Adds a noindex,nofollow to pages rendered using the application layout in Heroku review apps. Also disallows spiders from crawling this app using the robots.txt. The robots.txt will only be accessible from apps that are not behind router. This means that Heroku preview apps will indicate to crawlers that they should not index the site, but applications in production environments will be unaffected. --- app/views/development/index.html.erb | 1 + app/views/layouts/application.html.erb | 5 +++++ public/robots.txt | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/views/development/index.html.erb b/app/views/development/index.html.erb index 0de78fac4..b80c3aa10 100644 --- a/app/views/development/index.html.erb +++ b/app/views/development/index.html.erb @@ -4,6 +4,7 @@ government-frontend development page +
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 3561bcef6..5f47afccd 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -8,6 +8,11 @@ <%= @content_item.page_title %> - GOV.UK <% end %> + + <% if ENV['HEROKU_APP_NAME'].present? %> + + <% end %> + <%= stylesheet_link_tag "application", integrity: true, crossorigin: 'anonymous' %> <% if Rails.env.test? && params[:medium] == 'print' %> <%= stylesheet_link_tag "print.css", :media => "screen", integrity: true, crossorigin: 'anonymous' %> diff --git a/public/robots.txt b/public/robots.txt index 3c9c7c01f..f6ca098a0 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1,5 +1,5 @@ # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file # # To ban all spiders from the entire site uncomment the next two lines: -# User-agent: * -# Disallow: / +User-agent: * +Disallow: /