From 7231c988b78ce1878e0712b9bbacd1c022f84e0b Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Wed, 22 Jul 2020 11:12:24 +0200 Subject: [PATCH] add basic robots.txt --- CHANGELOG.md | 1 + exampleSite/config.yml | 2 ++ exampleSite/content/posts/how-to-use.md | 3 +++ layouts/partials/head.html | 8 ++++---- layouts/partials/site-footer.html | 4 +++- layouts/robots.txt | 3 +++ 6 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 layouts/robots.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 84cc354..9dcd711 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ - ENHANCEMENT - allow setting some common meta elements e.g. description and authors - prevent duplicate title on the start page + - add basic robots.txt - BUGFIX - dont display duplicate title on home page diff --git a/exampleSite/config.yml b/exampleSite/config.yml index 0a9c6b9..4edd7ee 100644 --- a/exampleSite/config.yml +++ b/exampleSite/config.yml @@ -51,6 +51,8 @@ outputs: - HTML - ATOM +enableRobotsTXT: true + params: geekblogSubtitle: Subtitle to describe your blog geekblogToC: 3 diff --git a/exampleSite/content/posts/how-to-use.md b/exampleSite/content/posts/how-to-use.md index 8a89867..cef939a 100644 --- a/exampleSite/content/posts/how-to-use.md +++ b/exampleSite/content/posts/how-to-use.md @@ -198,6 +198,9 @@ outputs: - HTML - ATOM +# Required if you want to render robots.txt template +enableRobotsTXT: true + params: # (Optional, default 6) Set how many table of contents levels to be showed on page. # Use false to hide ToC, note that 0 will default to 6 (https://gohugo.io/functions/default/) diff --git a/layouts/partials/head.html b/layouts/partials/head.html index e7cb127..e9fe032 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -20,16 +20,16 @@ {{ end }} {{ end }} -{{ if not (eq .Kind "home") }}{{ partial "title" . }} | {{ end }}{{ .Site.Title -}} +{{ if not (eq .Kind "home") }}{{ partial "title" . }} | {{ end }}{{ .Site.Title }} -{{ with .OutputFormats.Get "rss" -}} +{{ with .OutputFormats.Get "atom" }} {{ printf `` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} -{{ end -}} +{{ end }} -{{ "" | safeHTML }} diff --git a/layouts/partials/site-footer.html b/layouts/partials/site-footer.html index 75c4b2a..d7dbde4 100644 --- a/layouts/partials/site-footer.html +++ b/layouts/partials/site-footer.html @@ -1,10 +1,12 @@