aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <[email protected]>2019-08-02 17:26:25 +0300
committerGitHub <[email protected]>2019-08-02 17:26:25 +0300
commit1ebb8e7d9b4bd52c7fc088aeaec12ab9bcb240c6 (patch)
tree27a3a34ed43140503bab869090063946bbd4328f
parentca408b176b4d53e048a9d273a1a56bab36938c9e (diff)
downloadbootstrap-1ebb8e7d9b4bd52c7fc088aeaec12ab9bcb240c6.tar.xz
bootstrap-1ebb8e7d9b4bd52c7fc088aeaec12ab9bcb240c6.zip
robots.txt: adapt for Netlify. (#29192)
Since we build with `HUGO_ENV` set to `production` on Netlify, use another variable to prevent crawling.
-rw-r--r--site/layouts/robots.txt8
1 files changed, 6 insertions, 2 deletions
diff --git a/site/layouts/robots.txt b/site/layouts/robots.txt
index e9d78f1ae..c6703cd06 100644
--- a/site/layouts/robots.txt
+++ b/site/layouts/robots.txt
@@ -1,8 +1,12 @@
# www.robotstxt.org
-{{ if (eq (getenv "HUGO_ENV") "production") -}}
+{{- $isProduction := eq (getenv "HUGO_ENV") "production" -}}
+{{- $isNetlify := eq (getenv "NETLIFY") "true" -}}
+{{- $allowCrawling := and (not $isNetlify) $isProduction -}}
+
+{{ if $allowCrawling }}
# Allow crawling of all content
{{- end }}
User-agent: *
-Disallow:{{ if (ne (getenv "HUGO_ENV") "production") }} /{{ end }}
+Disallow:{{ if not $allowCrawling }} /{{ end }}
Sitemap: {{ .Site.BaseURL }}/sitemap.xml