Skip to content

Commit

Permalink
Ban indexing in preview apps
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sihugh committed Sep 3, 2019
1 parent 7493c6b commit b53d145
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/views/development/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<title>
government-frontend development page
</title>
<meta name="robots" content="noindex, nofollow">
</head>
<body>
<div id="wrapper">
Expand Down
5 changes: 5 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
<%= @content_item.page_title %> - GOV.UK
<% end %>
</title>

<% if ENV['HEROKU_APP_NAME'].present? %>
<meta name="robots" content="noindex, nofollow">
<% 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' %>
Expand Down
4 changes: 2 additions & 2 deletions public/robots.txt
Original file line number Diff line number Diff line change
@@ -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: /

0 comments on commit b53d145

Please sign in to comment.