Hi community,
I wonder if anybody knows a way to check that every page has title
defined? Ideally something that can be invoked for every Github PR.
Would like to avoid users updating our website without a valid set of “requirements”.
TIA
Hi community,
I wonder if anybody knows a way to check that every page has title
defined? Ideally something that can be invoked for every Github PR.
Would like to avoid users updating our website without a valid set of “requirements”.
TIA
layouts/_default/baseof.html
{{ partial "init.html" . }}
layouts/partials/init.html
{{ if .IsHome }}
{{ range where site.Pages "Title" "eq" "" }}
{{ errorf "Missing title: %s" .File.Path }}
{{ end }}
{{ end }}
We do the .IsHome
check to make sure the check is performed only once per site (language).
A build will still be launched, but it will error out almost immediately and the site won’t be updated. As far as doing this via a Github PR hook, that probably requires some bot integration into the repo to process a PR before merging or something.
This is perfect, and seems to be enough for what I want. We use Render, so every PR gets build and will fail if the property is missing.
I would love for this to be part of the hugo cli so I don’t have to keep my own version of baseof.html
. Something in the lines of hugo check pages --attribute-defined="title"
Thank you again!
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.