79202255

Date: 2024-11-19 06:19:46
Score: 0.5
Natty:
Report link

Hugo no longer displaying page

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:

There are (at least) 2 solutions:

1. Use Hugo 0.122.0

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:

2. Create proper Hugo structure

  1. Create a layout template for a single page at 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).

  1. Add Frontmatter to sunset.html

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 */

Why this Works

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:

  1. This is a content page (HTML with front matter)
  2. How to render it (single layout template)
  3. Where to serve it (/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.

Content Security Policy

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.

Reasons:
  • Blacklisted phrase (1): Stackoverflow
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Richard M.