From 8e9a5a5271d14d6c9403a2d834da2564452304ae Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Fri, 10 Jul 2026 08:42:32 -0700 Subject: [PATCH] Let hugo build the 404 page directly (#862) `postdeploy` copied site/public/404/index.html over to site/public/404.html after every deploy, because netlify serves /404.html for unmatched urls and hugo was not producing it. Hugo skips its native root 404.html whenever content/404.md exists: the content page claims the route and renders to /404/index.html instead. Point the page at /404.html with `url` front matter and hugo writes it where netlify wants it, so the copy is no longer needed. Drop it, and the netlify.toml note. Also drop the theme's layouts/404.html. It has never rendered, for the same reason, so its header comment describes a mechanism that does not exist. content/404.md is the real 404 page, and is what static/admin/config.yml offers up for editing. While here: exclude the page from the sitemap, and point its two pedalpalooza links straight at their bike-summer targets rather than through a 301. --- netlify.toml | 2 - package.json | 3 +- site/content/404.md | 11 +++- site/themes/s2b_hugo_theme/layouts/404.html | 59 --------------------- 4 files changed, 10 insertions(+), 65 deletions(-) delete mode 100644 site/themes/s2b_hugo_theme/layouts/404.html diff --git a/netlify.toml b/netlify.toml index 41033891..91a1e599 100644 --- a/netlify.toml +++ b/netlify.toml @@ -11,8 +11,6 @@ [build.environment] # extra environment variables if needed. -# we need to manually copy the 404 page over for now, in every environment -# cf https://github.com/shift-org/shift-docs/issues/862 [context.deploy-preview] # -D builds draft content for deploy previews # ( the doubledash is needed to pass the argument through to hugo ) diff --git a/package.json b/package.json index 4a648306..8ad6fd48 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,7 @@ "deploy": "concurrently --max-processes 1 -P 'npm:deploy:hugo -- {@}' 'npm:deploy:vite' --", "deploy:hugo": "exec-bin bin/hugo/hugo -s site", "deploy:vite": "npm -w cal run deploy", - "postdeploy": "cp site/public/404/index.html site/public/404.html", - + "postinstall": "hugo-installer --version 0.152.2", "test": "npm -w app test --", diff --git a/site/content/404.md b/site/content/404.md index dbd2fd94..40098ed4 100644 --- a/site/content/404.md +++ b/site/content/404.md @@ -1,14 +1,21 @@ --- title: 'Page not found' weight: '1' +# netlify serves this file for any unmatched url, so it has to +# land at /404.html rather than hugo's default /404/index.html. +# ( _default/list.html redirects there too. ) +url: '/404.html' +# ... and a "page not found" page has no business in the sitemap. +sitemap: + disable: true --- Whoops! I think your chain broke AND you got a flat tire at the same time. Don't worry! We'll help you get back on the road pretty quickly. Maybe you're looking for one of these pages? - [Event Calendar](/calendar) -- [Pedalpalooza Event Calendar](/pedalpalooza-calendar/) -- [Pedalpalooza information](/pages/pedalpalooza) +- [Bike Summer Event Calendar](/bike-summer-calendar/) +- [Bike Summer information](/pages/bike-summer) - [Breakfast on the Bridges](/pages/bonb) - [Move By Bike](/pages/mbb) diff --git a/site/themes/s2b_hugo_theme/layouts/404.html b/site/themes/s2b_hugo_theme/layouts/404.html deleted file mode 100644 index 8fd69fa4..00000000 --- a/site/themes/s2b_hugo_theme/layouts/404.html +++ /dev/null @@ -1,59 +0,0 @@ -{{/* - this file gets overwritten by netlify.toml - with 404.md on preview and deploy. - static/admin/config.yml points to that file as well. - - the apparent advantage is that 404.md - can reuse layout/_default/single.html -*/}} - - - - - {{ partial "head.html" . }} - - - - -
- -
- {{ partial "nav.html" . }} -
- -
-
- -
- -
- -

- - {{ .Title }} logo - -

- -

We are sorry - this page is not here anymore

-

Error 404 - Page not found

- -

Go to Homepage -

-
- - -
- -
- -
- - - - -
- - -