From 90c4092a7b72344b15471bb8c563a37f2627a985 Mon Sep 17 00:00:00 2001 From: Luca Matei Pintilie Date: Tue, 17 Dec 2024 17:49:33 +0100 Subject: [PATCH] site: SEO optimisations --- .github/workflows/deploy.yaml | 4 ++-- hugo.toml | 3 ++- themes/minecraft/layouts/_default/sitemap.xml | 24 +++++++++++++++++++ themes/minecraft/layouts/partials/head.html | 3 +++ themes/minecraft/layouts/partials/menu.html | 1 - themes/minecraft/layouts/robots.txt | 2 ++ 6 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 themes/minecraft/layouts/_default/sitemap.xml create mode 100644 themes/minecraft/layouts/robots.txt diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 72c7e12..29d5bd9 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -56,8 +56,8 @@ jobs: HUGO_ENVIRONMENT: production run: | hugo \ - --minify \ - --baseURL "${{ steps.pages.outputs.base_url }}/" + --minify --printMemoryUsage --printPathWarnings --printUnusedTemplates \ + --baseURL "${{ steps.pages.outputs.base_path }}" - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: diff --git a/hugo.toml b/hugo.toml index 98f0bb4..678a0e2 100644 --- a/hugo.toml +++ b/hugo.toml @@ -1,8 +1,9 @@ -baseURL = 'https://mcbe.wtf/' languageCode = 'en-us' title = 'Minecraft Bedrock Speedrunning' theme = "minecraft" copyright = 'Copyright @2024 Minecraft Speedrunning.' +enableGitInfo = true +enableRobotsTXT = true [taxonomies] tag = 'tags' diff --git a/themes/minecraft/layouts/_default/sitemap.xml b/themes/minecraft/layouts/_default/sitemap.xml new file mode 100644 index 0000000..373497b --- /dev/null +++ b/themes/minecraft/layouts/_default/sitemap.xml @@ -0,0 +1,24 @@ +{{ printf "" | safeHTML }} + + {{ range where .Pages "Sitemap.Disable" "ne" true }} + {{- if and .Permalink (not (hasPrefix .Path "/tags/")) -}} + + {{ .Permalink }}{{ if not .Lastmod.IsZero }} + {{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}{{ else }}{{ with .GitInfo }}{{ safeHTML ( .AuthorDate.Format "2006-01-02T15:04:05-07:00" ) }}{{ end }}{{ end }}{{ with .Sitemap.ChangeFreq }} + {{ . }}{{ end }}{{ if ge .Sitemap.Priority 0.0 }} + {{ .Sitemap.Priority }}{{ end }}{{ if .IsTranslated }}{{ range .Translations }} + {{ end }} + {{ end }} + + {{- end -}} + {{ end }} + diff --git a/themes/minecraft/layouts/partials/head.html b/themes/minecraft/layouts/partials/head.html index d54d46d..c8f156b 100644 --- a/themes/minecraft/layouts/partials/head.html +++ b/themes/minecraft/layouts/partials/head.html @@ -3,6 +3,9 @@ {{- with or .Description .Summary site.Params.description | plainify | htmlUnescape }} {{- end }} +{{ with .OutputFormats.Get "rss" -}} + {{ printf `` .Rel .MediaType.Type .Permalink site.Title | safeHTML }} +{{ end }} {{ template "_internal/opengraph.html" . }} {{ if .IsHome }}{{ site.Title }}{{ else }}{{ printf "%s | %s" .Title site.Title }}{{ end }} {{ partialCached "head/css.html" . }} diff --git a/themes/minecraft/layouts/partials/menu.html b/themes/minecraft/layouts/partials/menu.html index af49932..501024f 100644 --- a/themes/minecraft/layouts/partials/menu.html +++ b/themes/minecraft/layouts/partials/menu.html @@ -3,7 +3,6 @@ @context {page} page The current page. @context {string} menuID The menu ID. -@context {string} baseUrl The menu ID. @example: {{ partial "menu.html" (dict "menuID" "main" "page" .) }} */}} diff --git a/themes/minecraft/layouts/robots.txt b/themes/minecraft/layouts/robots.txt new file mode 100644 index 0000000..bdec164 --- /dev/null +++ b/themes/minecraft/layouts/robots.txt @@ -0,0 +1,2 @@ +User-Agent: * +Disallow: /tags/