Skip to content

build(hugo): let newer Hugo versions build the site at all - #638

Closed
Timur Tukaev (tym83) wants to merge 1 commit into
mainfrom
build/hugo-allowcontent-and-bump
Closed

build(hugo): let newer Hugo versions build the site at all#638
Timur Tukaev (tym83) wants to merge 1 commit into
mainfrom
build/hugo-allowcontent-and-bump

Conversation

@tym83

Copy link
Copy Markdown
Contributor

Summary

Anyone whose system Hugo is newer than the 0.160.1 pin cannot build this repo at all — not hugo server, not a plain hugo build. The failure is a wall of security-policy output that never mentions a version, so the natural conclusion is that the repo is broken rather than that a specific Hugo is required.

What

One config block. Hugo's default content policy is ! ^text/html$ — everything except HTML — so from 0.161 onwards an .html file is refused as a page source. This site's landing pages are exactly that, content/<lang>/_index.html in all five locales, so the build dies on the first one it reaches:

access denied: "text/html" is not whitelisted in policy "security.allowContent"

security.allowContent: ['.*'] restores it. Deliberately not narrowed to '^text/html$': the list is an allowlist, so that value would permit HTML and nothing else, and every markdown page would fail instead. That trap is written into the comment so the next person does not try it.

What this PR does not do

The pin stays at 0.160.1 and CI is untouched. I tried to bump it and backed out: a production build (hugo --gc --minify) on 0.161+ hits a second, unrelated wall. Hugo now runs PostCSS under Node's permission model with allowRead defaulting to the project directory, while Docsy's SCSS is read from the module cache outside it, so the transform fails with Access to this API has been restricted. Neither security.node.permissions.allowRead (the config does not expand $HOME or $HUGO_CACHEDIR) nor an in-project cacheDir cleared it — the latter fails config validation outright. Bumping the pin needs that solved first and deserves its own PR; the comment in hugo.yaml records where to start.

So after this change: dev and preview work on any version, production still needs 0.160.1. That is strictly better than today, where nothing works on a newer version.

Verification

  • hugo server / plain build: passes on both 0.160.1 and 0.164.0.
  • Pinned production build (hugo --gc --minify on 0.160.1): passes, 2592 pages, no errors — unchanged.
  • Also checked what a bump would have done to the output, in case it is useful later: 0.160.1 and 0.164.0 emit an identical set of 3629 files, and the only diff across the rendered HTML is indentation inside the head meta block, which Hugo's internal opengraph and twitter_cards templates now write with tabs.
  • The four existing deprecation warnings (module.mounts.lang, .Site.Data, .Language.LanguageName, .Language.LanguageDirection, plus the languageCode / languageName config keys) are not affected by this change — 0.160.1 emits them too. mounts.langsites.matrix touches the multilingual mount setup for five locales and is its own piece of work.

Hugo's default content policy is `! ^text/html$` — everything except HTML — so
from 0.161 onwards an .html file is refused as a page source. This site's landing
pages are exactly that, content/<lang>/_index.html in all five locales, so any
build on a newer Hugo dies on the first one it reaches with

  access denied: "text/html" is not whitelisted in policy "security.allowContent"

before rendering a single page, and the message never mentions a version. Anyone
whose system Hugo is newer than the pin cannot run `hugo server` or a plain
`hugo` build on this repo — which is a poor first encounter for a contributor
arriving to fix a typo.

Allow every content type back. Not narrowed to '^text/html$' deliberately:
allowContent is an allowlist, so that value permits HTML and nothing else, and
every markdown page fails instead.

The pin stays at 0.160.1 and CI is untouched. A production build
(`hugo --gc --minify`) on 0.161+ hits a second, unrelated wall: Hugo runs PostCSS
under Node's permission model with allowRead defaulting to the project directory,
while Docsy's SCSS is read from the module cache outside it, so the transform
fails with "Access to this API has been restricted". Neither
security.node.permissions.allowRead (the config does not expand $HOME or
$HUGO_CACHEDIR) nor an in-project cacheDir cleared it. Bumping the pin therefore
needs that solved first, and is left for its own change; the comment in hugo.yaml
records where the next person should start.

Verified: 0.160.1 and 0.164.0 both build in dev/preview mode with this config,
and the pinned 0.160.1 production build is unchanged — same 2592 pages, no errors.

Signed-off-by: Timur Tukaev <timur.tukaev@aenix.io>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@netlify

netlify Bot commented Aug 3, 2026

Copy link
Copy Markdown

Deploy Preview for cozystack ready!

Name Link
🔨 Latest commit 9345b23
🔍 Latest deploy log https://app.netlify.com/projects/cozystack/deploys/6a70878e3322e00008b1e8fc
😎 Deploy Preview https://deploy-preview-638--cozystack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8e430d20-a9e6-4e8f-bd24-6ba5e6c53bc4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@tym83

Copy link
Copy Markdown
Contributor Author

Closing as redundant — this landed in main first, and more thoroughly.

#636 (chore: upgrade Hugo to 0.164.0 and convert HTML content to markdown) and the follow-up requiring Node 22 solved both halves of the problem: the HTML landing pages are now markdown, so security.allowContent is not needed at all, and security.node.permissions.allowRead: ['*'] clears the PostCSS failure that stopped me from bumping the pin here.

For the record, since this PR's description claims otherwise: allowRead: ['*'] is sufficient on its own. I verified a production build (hugo --gc --minify) on 0.164.0 with Node 22 against the pre-#636 tree, HTML landing pages and all — it passes and emits the same 2592 pages. Converting the landings to markdown was the cleaner call, but it was not the blocker. My earlier attempts failed only because I wrote the path as '.' plus $HOME/.cache/hugo_cache, and the config does not expand environment variables.

The one thing worth carrying forward: the error a contributor sees on a newer Hugo says nothing about which version to install. Worth a line in CONTRIBUTING.md if anyone touches it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant