Skip to content

Commit b7a7dec

Browse files
johanrinclaude
andcommitted
Improve SEO with structured data fixes, sitemap config, and meta tags
- Enable enableGitInfo for accurate lastmod dates in sitemap and JSON-LD - Fix mainEntityOfPage in Article JSON-LD to use proper WebPage object - Fix duplicate og:url meta tag on post pages - Add sitemap configuration with changefreq and priority - Switch RSS feed from summary to full content - Use params.author.name instead of params.github in Article JSON-LD - Add keywords meta tag generated from post tags - Add publisher logo to Article JSON-LD for rich results eligibility Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6367287 commit b7a7dec

3 files changed

Lines changed: 27 additions & 5 deletions

File tree

hugo.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ defaultContentLanguage = "en-us"
99

1010
# Enable emojis globally
1111
enableEmoji = true
12+
13+
# Use git commit dates for .Lastmod (improves sitemap and structured data)
14+
enableGitInfo = true
1215
ignoreErrors = ["additional-script-loading-error"] # ignore error of loading additional scripts.
1316

1417
# traditional way: theme component resides in directory 'themes'
@@ -93,7 +96,7 @@ theme = "hugo-blog-awesome"
9396
# The file `custom.js` is loaded on each page (before body tag ends).
9497
dateFormat = "" # date format used to show dates on various pages. If nothing is specified, then "2 Jan 2006" format is used.
9598
# See https://gohugo.io/functions/time/format/ for available date formats.
96-
rssFeedDescription = "summary" # available options: 1) summary 2) full
99+
rssFeedDescription = "full" # available options: 1) summary 2) full
97100
# summary - includes a short summary of the blog post in the RSS feed. Generated using Hugo .Summary .
98101
# full - includes full blog post in the RSS feed. Generated using Hugo .Content .
99102
# By default (or if nothing is specified), summary is used.
@@ -147,5 +150,10 @@ url = "/index.xml"
147150
[caches.images]
148151
dir = ':cacheDir/images'
149152

153+
# Sitemap configuration for search engine crawlers
154+
[sitemap]
155+
changefreq = "weekly"
156+
priority = 0.5
157+
150158
# Generate robots.txt using an embedded template
151159
enableRobotsTXT = true

layouts/partials/custom-head.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@
5353
{{/* Canonical URL */}}
5454
<link rel="canonical" href="{{ .Permalink }}" />
5555

56-
{{/* Open Graph URL - for all pages */}}
56+
{{/* Open Graph URL - only for non-post pages (posts get og:url from meta/post.html) */}}
57+
{{ if ne .Section "posts" }}
5758
<meta property="og:url" content="{{ .Permalink }}" />
59+
{{ end }}
5860

5961
{{/* Open Graph Image dimensions for better social previews */}}
6062
<meta property="og:image:width" content="1200" />
@@ -64,6 +66,11 @@
6466
{{- $description := .Description | default .Site.Params.description -}}
6567
<meta name="twitter:image:alt" content="{{ $description }}" />
6668

69+
{{/* Keywords meta tag from post tags */}}
70+
{{ with .Params.tags }}
71+
<meta name="keywords" content="{{ delimit . ", " }}" />
72+
{{ end }}
73+
6774
{{/* Open Graph Type - set to "article" for posts, "website" for all other pages */}}
6875
{{ if eq .Section "posts" }}
6976
{{/* og:type="article" is already set in theme's meta/post.html */}}

layouts/partials/meta/post.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,15 @@
4444
"headline": {{ .Title }},
4545
"author": {
4646
"@type": "Person",
47-
"name": "{{ .Site.Params.github }}"
47+
"name": "{{ .Site.Params.author.name }}"
4848
},
4949
"datePublished": "{{ dateFormat "2006-01-02" .Date }}",
5050
"description": {{ .Description }},
5151
"wordCount": {{ .WordCount }},
52-
"mainEntityOfPage": "True",
52+
"mainEntityOfPage": {
53+
"@type": "WebPage",
54+
"@id": "{{ .Permalink }}"
55+
},
5356
"dateModified": "{{ dateFormat "2006-01-02" .Lastmod }}",
5457
"image": {
5558
"@type": "ImageObject",
@@ -59,7 +62,11 @@
5962
},
6063
"publisher": {
6164
"@type": "Organization",
62-
"name": "{{ .Site.Title }}"
65+
"name": "{{ .Site.Title }}",
66+
"logo": {
67+
"@type": "ImageObject",
68+
"url": "{{ .Site.BaseURL }}avatar.jpg"
69+
}
6370
}
6471
}
6572
</script>

0 commit comments

Comments
 (0)