Skip to content

Commit 5e793b8

Browse files
committed
Add noindex metatag to mobile specific pages
The publications will be linked to from mobile. We don't want them being indexed by search engines as they should be solely consumed by users of the GOV.UK mobile app.
1 parent 376dcbb commit 5e793b8

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

app/presenters/publication_presenter.rb

+10-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,16 @@ def dataset?
2626
%(national_statistics official_statistics transparency).include? document_type
2727
end
2828

29-
# this is a temporary hack and should be removed in approx 3 months
3029
def hide_from_search_engines?
31-
content_item["base_path"] == "/government/publications/pension-credit-claim-form--2"
30+
# this is a temporary hack and should be removed in approx 3 months
31+
return true if content_item["base_path"] == "/government/publications/pension-credit-claim-form--2"
32+
33+
mobile_paths = %w[
34+
/government/publications/govuk-app-terms-and-conditions
35+
/government/publications/govuk-app-privacy-notice-how-we-use-your-data
36+
/government/publications/govuk-app-test-privacy-notice-how-we-use-your-data
37+
/government/publications/accessibility-statement-for-the-govuk-append
38+
]
39+
mobile_paths.include?(content_item["base_path"])
3240
end
3341
end

test/integration/publication_test.rb

+14
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,20 @@ class PublicationTest < ActionDispatch::IntegrationTest
300300
assert page.has_css?('meta[name="robots"][content="noindex"]', visible: false)
301301
end
302302

303+
test "adds the noindex meta tag to mobile paths" do
304+
mobile_paths = %w[
305+
/government/publications/govuk-app-terms-and-conditions
306+
/government/publications/govuk-app-privacy-notice-how-we-use-your-data
307+
/government/publications/govuk-app-test-privacy-notice-how-we-use-your-data
308+
/government/publications/accessibility-statement-for-the-govuk-append
309+
]
310+
mobile_paths.each do |path|
311+
overrides = { "base_path" => path }
312+
setup_and_visit_content_item("publication-with-featured-attachments", overrides)
313+
assert page.has_css?('meta[name="robots"][content="noindex"]', visible: false)
314+
end
315+
end
316+
303317
test "translates Welsh published date correctly" do
304318
setup_and_visit_content_item("publication", { "locale" => "cy" })
305319

test/presenters/publication_presenter_test.rb

+15
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,19 @@ def schema_name
101101

102102
assert presented.hide_from_search_engines?
103103
end
104+
105+
test "hide_from_search_engines? returns true if the page is related to mobile" do
106+
schema_example = schema_item("publication-with-featured-attachments")
107+
mobile_paths = %w[
108+
/government/publications/govuk-app-terms-and-conditions
109+
/government/publications/govuk-app-privacy-notice-how-we-use-your-data
110+
/government/publications/govuk-app-test-privacy-notice-how-we-use-your-data
111+
/government/publications/accessibility-statement-for-the-govuk-append
112+
]
113+
mobile_paths.each do |path|
114+
schema_example["base_path"] = path
115+
presented = presented_item("publication", schema_example)
116+
assert presented.hide_from_search_engines?
117+
end
118+
end
104119
end

0 commit comments

Comments
 (0)