SEO audits › Hugo
Hugo SEO checklist
Hugo, the static site generator, gives you a sitemap out of the box and leaves most other SEO work to your theme. Canonical tags, meta descriptions and structured data only exist if the templates in layouts/ print them, so two Hugo sites can behave very differently.
This checklist goes through each piece with the config keys and template code to use, checked against the current Hugo docs (v0.170). Template paths follow the layout introduced in v0.146.0, where files sit directly under layouts/ and partials live in layouts/_partials/. On older versions the same files live under layouts/_default/ and layouts/partials/.
Run a free audit on your Hugo site
All 140+ checks, no credit card. Last reviewed 2026-11-26.
Hugo sitemap: generating, customizing and disabling it
Hugo generates a sitemap for you on every build, with no configuration. On a single-language site it is sitemap.xml in the root of public/. On a multilingual site Hugo writes one sitemap per language plus a sitemap index at the root.
URLs in the sitemap are built from baseURL, so that has to be your production address. Each entry gets a <lastmod> when the page has a last-modified date, which comes from lastmod or date in front matter, or from Git history if you set enableGitInfo = true.
To customize it, set defaults under [sitemap] in your project configuration and override them per page in front matter. To leave a page out, set disable = true in that page's sitemap front matter. To stop generating a sitemap at all, add sitemap to disableKinds.
hugo.toml, then front matter for one page
# hugo.toml
baseURL = 'https://example.org/'
enableGitInfo = true # lastmod from the last Git commit of each file
[sitemap]
changeFreq = '' # empty: omit <changefreq>
priority = -1 # -1: omit <priority>
filename = 'sitemap.xml'
# To turn the sitemap off entirely:
# disableKinds = ['sitemap']
# content/thank-you.md
+++
title = 'Thank you'
[sitemap]
disable = true
+++
For anything the settings do not cover, override the embedded template by creating layouts/sitemap.xml (and layouts/sitemapindex.xml for the multilingual index). Start from Hugo's embedded template so you keep the Sitemap.Disable filter. The sitemap templates page links to the source.
The default sitemap lists every page Hugo renders, including taxonomy and term pages such as /tags/ and /tags/foo/. If you noindex those or do not want them indexed, exclude them too. A sitemap should only contain URLs that return 200 and that you want in search results.
Wrendex checks for this: Sitemap URL returns 4xx, Sitemap URL redirects, Sitemap URL is noindex, Sitemap URL non-canonical, URL missing from sitemap
Hugo robots.txt with enableRobotsTXT and a custom template
Hugo does not write a robots.txt unless you ask for one. Set enableRobotsTXT = true in your project configuration and Hugo generates /robots.txt from an embedded template whose whole output is User-agent: *, which allows everything.
To control the contents, create layouts/robots.txt. It is a normal Hugo template, so you can print the sitemap URL from baseURL and add rules per section.
hugo.toml and layouts/robots.txt
# hugo.toml
enableRobotsTXT = true
# layouts/robots.txt
User-agent: *
Disallow: /search/
Sitemap: {{ "sitemap.xml" | absURL }}
If you would rather hand-write the file, leave enableRobotsTXT set to false and put robots.txt in the static directory. Hugo copies everything in static to the root of public/ at build time. Use one approach or the other.
On a multilingual site with a single host Hugo generates one robots.txt at the root. On a multihost setup it generates one per language, and you can give a language its own template, such as layouts/robots.de.txt.
robots.txt stops crawling, not indexing. A page blocked with Disallow can still be indexed from links, and crawlers cannot see a noindex tag on a page they are not allowed to fetch.
Wrendex checks for this: robots.txt inaccessible
Hugo canonical URLs with baseURL and .Permalink
Hugo does not add a canonical tag on its own. Your theme has to print one, and the right value is .Permalink, which returns the absolute URL of the page built from baseURL.
So there are two things to get right. Set baseURL to the full production URL, with protocol, host, any path and a trailing slash. Then print <link rel="canonical"> in the <head> of your base template.
hugo.toml and layouts/baseof.html
# hugo.toml
baseURL = 'https://example.org/'
<!-- layouts/baseof.html, inside <head> -->
<link rel="canonical" href="{{ or .Params.canonical .Permalink }}">
# Optional per-page override in front matter
+++
title = 'Syndicated post'
[params]
canonical = 'https://original.example.com/post/'
+++
Most canonical problems on Hugo sites trace back to baseURL. Common ones: it is still the https://example.org/ default, it says http:// while the site is served over HTTPS, it has www when the live site does not, or the deploy overrides it with --baseURL for a preview domain and that build reaches production. View source on the live site and check the tag.
Use .Permalink for canonicals, sitemaps and Open Graph URLs, and .RelPermalink for ordinary links between pages.
A crawl will show pages with no canonical, canonicals that point at a redirect or a 404, and HTTPS pages that canonicalize to HTTP.
Wrendex checks for this: Duplicates without canonical, Canonical points to redirect, Canonical points to 4xx, Canonical https to http, Non-canonical declared as canonical, og:url and canonical disagree
Hugo noindex
Hugo has no noindex setting. You add a custom front matter parameter and have your head template print <meta name="robots" content="noindex"> when it is set.
Custom parameters go under params in front matter and are read with .Params in templates. Set sitemap.disable on the same page so it also drops out of the sitemap.
Front matter and the head template
# content/thank-you.md
+++
title = 'Thank you'
[sitemap]
disable = true
[params]
robots = 'noindex'
+++
<!-- layouts/baseof.html, inside <head> -->
{{ with .Params.robots }}
<meta name="robots" content="{{ . }}">
{{ end }}
Do not also block the page in robots.txt. A crawler has to fetch the page to see the noindex.
Check what your theme already does before adding this. Some themes print a robots meta tag from their own parameter or by environment, and two tags that disagree are worse than one. Search the theme's layouts folder for robots.
After deploying, crawl the site and review the list of noindex pages. It should contain the pages you marked and nothing else.
Wrendex checks for this: Page is noindex, Conflicting noindex signals, Sitemap URL is noindex, Page became non-indexable
Hugo meta descriptions
Set description in each page's front matter and print it with .Description in your head template. Hugo stores the field but does not output a meta description tag unless a template does.
Pages without a description need a fallback or they ship with no tag at all. The pattern Hugo's own embedded templates use is the page description, then the page summary, then a site-wide params.description.
Front matter, hugo.toml and the head template
# content/recipes/sushi.md
+++
title = 'How to make spicy tuna hand rolls'
description = 'Instructions for making spicy tuna hand rolls.'
+++
# hugo.toml
[params]
description = 'Recipes and techniques for home sushi.'
<!-- layouts/baseof.html, inside <head> -->
{{ with or .Description .Summary site.Params.description | plainify | htmlUnescape }}
<meta name="description" content="{{ trim . "\n\r\t " | truncate 160 }}">
{{ end }}
The fallbacks keep the tag from being empty, but they are not a substitute for writing descriptions. An automatic summary is the opening of the page, cut at about 70 words by default, and the site-wide value is identical on every page that falls through to it. List pages such as sections, tags and the home page take their description from the front matter of their _index.md.
Do the same check for <title>. A common theme pattern prints only site.Title on list pages, which gives every tag and section page the same title.
A crawl reports pages with a missing, duplicated, too short or too long description, so you can see which content files still need one.
Wrendex checks for this: Meta description missing, Duplicate meta description, Meta description too long, Meta description too short, Duplicate title across pages, Page title missing
Hugo custom 404 page
Create layouts/404.html. Hugo renders it to 404.html at the root of the published site. For a multilingual site, add the language key to the file name, such as 404.de.html and 404.en.html.
Hugo only builds the file. Serving it for missing URLs, with a 404 status, is the job of your web server or host. GitHub Pages does this automatically. Most other hosts and servers need a setting or a rule.
layouts/404.html, and the nginx rule that serves it
{{ define "main" }}
<h1>404 Not Found</h1>
<p>The page you requested cannot be found.</p>
<p>
<a href="{{ site.Home.RelPermalink }}">
Return to the home page
</a>
</p>
{{ end }}
# nginx, inside the server block
error_page 404 /404.html;
The template above fills the main block of your baseof.html, so the 404 page keeps your site header and menu.
The 404 templates page links to the instructions for each host, including Netlify, Cloudflare Pages, Amazon S3 and CloudFront, Azure, Firebase, Apache and Caddy.
Test it on the deployed site: request a URL that does not exist and confirm the status is 404 and not 200. A custom error page served with a 200 is a soft 404, and search engines may keep those URLs around. Then fix the internal links that lead to 404s. A crawl lists each one with the page it was found on.
Wrendex checks for this: 404 Not Found, 4xx client error, Links to broken page
Hugo redirects: aliases and server-side redirects on your host
To redirect an old URL to a page in Hugo, list the old path in that page's aliases front matter. Paths with a leading slash are relative to the site root. Paths without one are relative to the page.
By default this is a client-side redirect. Hugo writes a small HTML file at each alias path containing a <meta http-equiv="refresh"> tag and a canonical link to the new URL. It works on any host, but the server answers 200, not 301.
For real 301s, let your host do the redirect and have Hugo generate the rules. Set disableAliases = true so the HTML files are not written, then build a _redirects file (used by Netlify, Cloudflare and GitLab Pages) from the .Aliases method with a custom output format.
Front matter, hugo.toml and layouts/home.redirects
# content/posts/new-name.md
+++
title = 'New name'
aliases = ['/old-url', 'old-name']
+++
# hugo.toml
disableAliases = true
[mediaTypes]
[mediaTypes.'text/redirects']
delimiter = ''
[outputFormats]
[outputFormats.redirects]
baseName = '_redirects'
isPlainText = true
mediaType = 'text/redirects'
root = true
[outputs]
home = ['html', 'redirects']
{{/* layouts/home.redirects */}}
{{- if site.IsDefault -}}
{{- range hugo.Sites -}}
{{- range $p := .Pages -}}
{{- range .Aliases -}}
{{- if findRE `\s` . -}}
{{- errorf "One of the front matter aliases in %q contains whitespace" $p.String -}}
{{- end -}}
{{- printf "%s %s 301\n" . $p.RelPermalink -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
The build then produces a _redirects file with one line per alias, in the form /old-url /posts/new-name/ 301. The config and template come from the Hugo docs page for the Aliases method. The same approach can generate an .htaccess file for Apache.
Aliases only cover URLs that map to a page in your content. Anything else, such as forcing HTTPS, www to the bare domain, or a pattern covering a whole old directory, belongs in your host or server config.
After moving content, crawl the site. Wrendex flags meta refresh redirects, internal links that still point at the old URL, redirect chains and redirects that land on a missing page.
Wrendex checks for this: Meta refresh redirect, Redirect chain, Broken redirect, Redirect loop, Links to redirected page
Hugo structured data
Hugo includes embedded templates for Open Graph, X (Twitter) Cards and schema.org microdata, and none of them produce JSON-LD. For the JSON-LD that Google's rich results documentation asks for, you write a small partial.
The embedded templates are called as partials from your head template: {{ partial "opengraph.html" . }}, {{ partial "twitter_cards.html" . }} and {{ partial "schema.html" . }}. They read the page title, description, dates and images from front matter, with params.description and params.images in your project configuration as fallbacks. The schema one prints microdata <meta itemprop> tags in the head.
For JSON-LD, build a dict and print it with jsonify. Encoding the whole object is safer than hand-writing JSON with template variables inside it, where a quote in a title breaks the markup.
layouts/_partials/jsonld.html
{{- if .IsPage }}
{{- $iso := "2006-01-02T15:04:05Z07:00" }}
{{- $schema := dict
"@context" "https://schema.org"
"@type" "Article"
"headline" .Title
"description" .Description
"datePublished" (.PublishDate.Format $iso)
"dateModified" (.Lastmod.Format $iso)
"mainEntityOfPage" .Permalink
}}
<script type="application/ld+json">{{ $schema | jsonify | safeJS }}</script>
{{- end }}
Call it from the <head> of layouts/baseof.html with {{ partial "jsonld.html" . }}. The .IsPage test limits it to regular content pages, so list pages and the home page do not claim to be articles.
Give every page a date in front matter. A page with no date renders 0001-01-01 as its publish date, which validators reject. Add image and author to the dict if you have them in front matter, since Google's Article guidance recommends both.
To change what the embedded Open Graph or schema templates print, copy the source to a file of the same name in layouts/_partials/ and edit it. The embedded templates page links to each source file.
A crawl validates the JSON-LD on every page, which catches the per-page failures a single test URL will miss: output that does not parse, empty fields and invalid dates.
Wrendex checks for this: JSON-LD parse error, Google rich result missing required field, Google rich result invalid date, Google rich result empty field, Missing Open Graph tags, Missing Twitter Card
Sources
- Hugo Docs: Sitemap templates
- Hugo Docs: Configure sitemap
- Hugo Docs: robots.txt template
- Hugo Docs: All settings (baseURL, disableKinds, enableGitInfo, enableRobotsTXT)
- Hugo Docs: Permalink method
- Hugo Docs: Description method
- Hugo Docs: Front matter
- Hugo Docs: Content summaries
- Hugo Docs: Custom 404 page
- Hugo Docs: URL management (aliases)
- Hugo Docs: Aliases method
- Hugo Docs: Embedded partial templates
- Hugo Docs: encoding.Jsonify