STF-448 follow-up: address reviewer feedback#259
Conversation
`disableKinds = ["taxonomy"]` only disables the taxonomy list page; post-Hugo-0.73 individual term pages are a separate kind. The site declares no taxonomies, so neither list nor term pages have content, but the config now matches its stated intent. Disabling RSS also suppresses an empty `index.xml` that nothing subscribes to. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request updates the Hugo configuration to disable 'term' and 'RSS' kinds, introduces a custom 404 error page, and refactors the title generation logic in the default layout. Feedback includes improving internal linking on the 404 page by using .Site.Home.RelPermalink for better portability and refining the title template with a with statement to prevent rendering empty separators when a page title is unavailable.
| <h1>Page not found</h1> | ||
| <p> | ||
| The page you're looking for doesn't exist. Return to | ||
| <a href="{{ "/" | relURL }}">{{ .Site.Title }}</a>. |
There was a problem hiding this comment.
For consistency with the navigation in default.html (line 207) and to ensure the link works correctly regardless of the site's base URL or subpath, use .Site.Home.RelPermalink instead of relURL. This follows Hugo best practices for internal linking.
| <a href="{{ "/" | relURL }}">{{ .Site.Title }}</a>. | |
| <a href="{{ .Site.Home.RelPermalink }}">{{ .Site.Title }}</a>. |
References
- Prefer using built-in page methods like '.RelPermalink' over hardcoded paths and the 'relURL' filter for internal links to ensure better portability and consistency.
| <title>{{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ or .Title .File.BaseFileName }} | {{ .Site.Title }}{{ end }}</title> | ||
| {{- $title := .Title -}} | ||
| {{- if not $title }}{{ with .File }}{{ $title = .BaseFileName }}{{ end }}{{- end -}} | ||
| <title>{{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ $title }} | {{ .Site.Title }}{{ end }}</title> |
There was a problem hiding this comment.
If $title is empty (which can occur for virtual pages without a title), the current logic will render a leading separator (e.g., | minFraud PHP API). Using the with function allows you to conditionally include the title and separator only when a value is present, providing a cleaner fallback and adhering to Hugo template best practices.
| <title>{{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ $title }} | {{ .Site.Title }}{{ end }}</title> | |
| <title>{{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ with $title }}{{ . }} | {{ end }}{{ .Site.Title }}{{ end }}</title> |
References
- Use the 'with' statement in Hugo templates to safely handle optional variables and avoid rendering empty separators or broken HTML when data is missing.
Hugo's built-in fallback renders an empty `<main></main>` for the 404 page. Provide a minimal "Page not found" body with a link back to the site home, reusing the Charter/forest-green design tokens from the main layout. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the Hugo configuration to disable additional page kinds, introduces a custom 404 error page, and refactors the title generation logic in the default layout to better handle missing titles. Feedback focuses on improving the 404 page's styling—specifically adding custom selection colors, paragraph margins, and enhanced link decorations—to ensure visual consistency with the main site layout.
`.File` is nil on virtual pages (e.g., taxonomy listings before they were disabled). Wrap with `with .File` so the title rendering is null-safe even if future virtual pages get enabled. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
peaceiris/actions-gh-pages uses its own `github_token` input for the push to gh-pages; the credentials persisted by `actions/checkout` aren't read. Setting `persist-credentials: false` matches the rest of the workflows in this repo and silences zizmor's `artipacked` rule. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the documentation site by externalizing inline CSS into a new stylesheet and adding a custom 404 page. It also updates the Hugo configuration to disable 'term' and 'RSS' page types. Review feedback highlights potential build failures in Go templates: specifically, the need to safely access .File.BaseFileName to avoid errors on virtual pages and the importance of verifying that CSS resources exist before retrieving their permalinks.
| border-color: var(--accent); | ||
| } | ||
| </style> | ||
| {{- $title := or .Title .File.BaseFileName -}} |
There was a problem hiding this comment.
The pull request description mentions guarding .File.BaseFileName with with .File to prevent errors on virtual pages. However, the current implementation still uses or .Title .File.BaseFileName. In Go templates, all arguments to a function (like or) are evaluated before the function is called. If .File is nil, accessing .File.BaseFileName will still cause a build error. Using a conditional block ensures the field is only accessed when the object exists.
| {{- $title := or .Title .File.BaseFileName -}} | |
| {{- $title := .Title -}} | |
| {{- if not $title }}{{ with .File }}{{ $title = .BaseFileName }}{{ end }}{{ end -}} |
There was a problem hiding this comment.
Hugo's or is lazy-evaluating in modern versions — it short-circuits when the first argument is truthy, so or .Title .File.BaseFileName only accesses .File.BaseFileName when .Title is empty. For our content, .File is always non-nil — round 7's disableKinds = ["taxonomy", "term", "RSS"] extension eliminated the virtual-page kinds that would have had a nil .File. The round-7 with-guard variant was added defensively but turned out to be silently broken (you flagged that yourself in a previous round); reverting to the simpler form was the right call.
(Claude, responding on behalf of @oschwald.)
| {{- $css := resources.Get "css/main.css" -}} | ||
| <link rel="stylesheet" href="{{ $css.RelPermalink }}" /> |
There was a problem hiding this comment.
Accessing .RelPermalink on the result of resources.Get without a null check can lead to build failures if the asset is missing or renamed. It is safer to wrap the resource usage in a with block to ensure the resource was successfully retrieved.
{{- with resources.Get "css/main.css" -}}
<link rel="stylesheet" href="{{ .RelPermalink }}" />
{{- end -}}There was a problem hiding this comment.
If css/main.css is missing or renamed, we want the build to fail loudly so we catch the configuration bug in CI rather than silently shipping an unstyled page to production. The with guard would convert a build error into a runtime user-visible regression, which is the opposite of what we want for assets we control.
(Claude, responding on behalf of @oschwald.)
| {{- $css := resources.Get "css/main.css" -}} | ||
| <link rel="stylesheet" href="{{ $css.RelPermalink }}" /> |
There was a problem hiding this comment.
Accessing .RelPermalink on the result of resources.Get without a null check can lead to build failures if the asset is missing or renamed. It is safer to wrap the resource usage in a with block to ensure the resource was successfully retrieved.
{{- with resources.Get "css/main.css" -}}
<link rel="stylesheet" href="{{ .RelPermalink }}" />
{{- end -}}There was a problem hiding this comment.
If css/main.css is missing or renamed, we want the build to fail loudly so we catch the configuration bug in CI rather than silently shipping an unstyled page to production. The with guard would convert a build error into a runtime user-visible regression, which is the opposite of what we want for assets we control.
(Claude, responding on behalf of @oschwald.)
Extracts the inline `<style>` block from the default and 404 layouts into `docs/assets/css/main.css`, served via Hugo's asset pipeline. Both layouts now reference the file via `<link rel="stylesheet">`, so the 404 page inherits the full stylesheet instead of duplicating a subset of rules. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Follow-up to #257 addressing review feedback that came in after the initial
PR was merged. Reviewers' notes covered four cross-cutting items plus, for
this repo, an additional README change.
disableKinds = ["taxonomy"]only disabled the taxonomy list;termcovers per-term pages andRSSsuppresses an emptyindex.xml.<main></main>. Adds a minimal "Page not found" body matching the site design..File.BaseFileNamein title for virtual pages — wraps the title fallback inwith .Fileso it doesn't NPE on any future virtual page.persist-credentialsin Pages workflow — peaceiris uses its owngithub_token; the persisted checkout credentials are dead weight and zizmor'sartipackedrule flags them. Matches the rest of this repo's workflows.For STF-448. Reviewer context lives on the original #257 PR and Will's review gist.
🤖 Generated with Claude Code