]> danix's work - danix.xyz-2.git/commitdiff
feat: Add SEO meta tags — canonical and hreflang alternates
authorDanilo M. <redacted>
Tue, 21 Apr 2026 13:05:45 +0000 (15:05 +0200)
committerDanilo M. <redacted>
Tue, 21 Apr 2026 13:05:45 +0000 (15:05 +0200)
- Create robots.txt template with Sitemap directive and JSON search index exclusions
- Add canonical link and hreflang alternates (it, en, x-default) to all pages
- Uses Hugo built-ins (.Permalink, .AllTranslations) for production-correct URLs
- All pages now signal canonical URL and language variants to search engines

Co-Authored-By: Claude Haiku 4.5 <redacted>
themes/danix-xyz-hacker/layouts/partials/head-meta.html
themes/danix-xyz-hacker/layouts/robots.txt [new file with mode: 0644]

index 5c6ed8b3b986041508068d37bb7b8ba64ae74ca5..45fd476bc358d21bf2a6232a209a781fa5f17e3d 100644 (file)
 {{ with .Site.Params.twitterHandle }}
 <meta name="twitter:site" content="@{{ . }}">
 {{ end }}
+
+{{/* SEO: Self-referencing canonical */}}
+<link rel="canonical" href="{{ .Permalink }}">
+
+{{/* SEO: hreflang alternates for all language variants */}}
+{{ range .AllTranslations }}
+<link rel="alternate" hreflang="{{ .Language.Lang }}" href="{{ .Permalink }}">
+{{ end }}
+{{/* x-default: EN version (served at root /) */}}
+{{ range .AllTranslations }}
+  {{ if eq .Language.Lang "en" }}
+<link rel="alternate" hreflang="x-default" href="{{ .Permalink }}">
+  {{ end }}
+{{ end }}
diff --git a/themes/danix-xyz-hacker/layouts/robots.txt b/themes/danix-xyz-hacker/layouts/robots.txt
new file mode 100644 (file)
index 0000000..8fc0c20
--- /dev/null
@@ -0,0 +1,5 @@
+User-agent: *
+Disallow: /search-index.json
+Disallow: /it/search-index.json
+
+Sitemap: {{ .Site.BaseURL }}sitemap.xml