From e94a222c9cf28be8884867696222296fc710b985 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sat, 14 May 2022 00:58:20 +0200 Subject: Rework robots.txt file --- exampleSite/config.toml | 6 ++++++ layouts/robots.txt | 14 +++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 998bf5a..4bf5dcb 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -5,6 +5,7 @@ defaultContentLanguage = 'en' title = 'Ed.' theme = ['github.com/sergeyklay/gohugo-theme-ed'] resourceDir = '../resources' +enableRobotsTXT = true [languages] [languages.en] @@ -68,6 +69,11 @@ resourceDir = '../resources' name = 'Documentation' url = '/documentation/' weight = 4 + [[menu.main]] + identifier = 'search' + name = 'Search' + url = '/search/' # TODO: Implement search + weight = 5 [[menu.main]] identifier = 'github' name = 'GitHub Project' diff --git a/layouts/robots.txt b/layouts/robots.txt index 7a24e82..9f95983 100644 --- a/layouts/robots.txt +++ b/layouts/robots.txt @@ -1,8 +1,12 @@ +{{- $url := urls.Parse site.BaseURL -}} +# robots.txt file for "{{ site.Title }}", {{ $url.Host }} User-agent: * -# robotstxt.org - if ENV production variable is false robots will be disallowed. -{{ if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production") }} +{{- if eq (getenv "HUGO_ENV") "production" | or (eq site.Params.env "production") }} Allow: / -Sitemap: {{.Site.BaseURL}}/sitemap.xml -{{ else }} +Sitemap: {{ site.BaseURL }}/sitemap.xml +{{- else }} Disallow: / -{{ end }} +{{- end }} + +# TODO: implement sitemap.xml +# Sitemap: {{ site.BaseURL }}/sitemap.xml -- cgit v1.2.3