From b4125630c83df5a881f4a426b69381b13565590e Mon Sep 17 00:00:00 2001 From: walsh9 Date: Thu, 15 Jun 2023 12:23:11 -0400 Subject: [PATCH] Exclude search pages from indexing with robots meta tag instead of robots.txt (#289) * Exclude search pages with robots meta tag instead of robots.txt --- pages/search.vue | 5 +++++ public/robots-prod.txt | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pages/search.vue b/pages/search.vue index 25029b18..d87138da 100644 --- a/pages/search.vue +++ b/pages/search.vue @@ -48,10 +48,15 @@ useHeadSafe({ useServerHeadSafe({ meta: [{ property: 'og:title', content: pageTitle}] }) +if (query.value) { + useServerHead({meta: [{name: 'robots', content: 'noindex'}]}) +} useChartbeat() useOptinMonster() + + onMounted(() => { $analytics.sendPageView({ page_type: 'search_page' }) getSearchResults() diff --git a/public/robots-prod.txt b/public/robots-prod.txt index 75e65d70..9283414d 100644 --- a/public/robots-prod.txt +++ b/public/robots-prod.txt @@ -1,7 +1,6 @@ User-agent: * Disallow: /mt/ Disallow: /profile/ -Disallow: /search?q=* Sitemap: https://gothamist.com/sitemap.xml Sitemap: https://gothamist.com/sitemap-news.xml