The issue stems from a breaking change introduced in Hugo 0.123.0 that introduced stricter rules on how the Hugo interpreter handles raw (those without frontmatter/templates) HTML files in the content directory. Previously, Hugo would serve raw HTML files directly, but now it requires proper Hugo structure and templates.
Here's some related reading from the Hugo repo going over the changes and their motivations:
Modify your .github/workflows/hugo.yaml
:
jobs:
build:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.122.0
This will render sunset.html
as you previously had it (I tested it by forking your repo).
It's not the best option long-term because:
But hey, these are problems for later down the road, solution 1 will work for now. However if you want to fix the problem permanently, well then I recommend solution 2:
layouts/_default/single.html
{{ .Content }}
This page variable will mean that the all the Content of the content page (the content page in this case is sunset.html
) is rendered, Hugo knows that the content page is of type HTML so it will parse the HTML correctly (instead of just having the raw HTML be displayed, <'s and all).
Frontmatter allows more control over your Hugo site, both by you and by Hugo. Though not strictly required for this use-case (sunset.html will render without it), it would be good practice to add some to the file.
(As an aside, if you use the Hugo CLI that comes installed with Hugo to create content via hugo new <CONTENT-NAME>
, then your existing archetype file will be inherited by that content file, meaning the frontmatter will be created automatically.)
---
title: "Sunset"
date: 2024-11-19
draft: false
---
/* rest of sunset.html */
The original setup treated sunset.html
as a page resource in a leaf bundle. From Hugo version 0.123.0 onward, raw HTML files without front matter are no longer automatically processed as pages. By adding the front matter and layout template, we explicitly tell Hugo:
/gift/ckeesee/sunset
)Putting single.html
in layouts/_default/
will mean all individual content pages (any page that isn't a list/homepage, how to tell the difference here) will use that layout. If it causes more changes than you'd like, then you can restrict the layout file to affect just the content pages under content/gift
by moving single.html
to layouts/gift/single.html
.
The content-security-policy error you mentioned requires more information to resolve and is a little outside of the scope of your Hugo deployment problem. If you're still having issues with it feel free to create another separate question and I'll do my best to assist you (include the exact CSP error from your browser).
In the meantime here's a Stackoverflow reply that can give some information on what kind of issue a CSP issue is. It includes a link to the relevant Mozilla developer page and a link to the Google CSP Evaluator which is a tool that can look at your Content Security Policy and find problems. Give it a try, hopefully it can help.