diff options
| author | XhmikosR <[email protected]> | 2019-08-02 17:26:25 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-08-02 17:26:25 +0300 |
| commit | 1ebb8e7d9b4bd52c7fc088aeaec12ab9bcb240c6 (patch) | |
| tree | 27a3a34ed43140503bab869090063946bbd4328f | |
| parent | ca408b176b4d53e048a9d273a1a56bab36938c9e (diff) | |
| download | bootstrap-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.txt | 8 |
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 |
