Deploy docs site with Hugo and GitHub Actions#434
Conversation
There was a problem hiding this comment.
Code Review
This pull request migrates the project documentation from Jekyll to Hugo. It removes the manual documentation generation logic from the release script, adds Hugo configuration and layouts, and introduces mise tasks for building and serving the site. Review feedback focuses on refining the Hugo implementation, specifically restoring descriptive page titles lost during the migration, improving title tag logic, utilizing link titles in navigation, and pinning the Hugo version in the configuration for better build reproducibility.
| [[cascade]] | ||
| layout = "default" |
There was a problem hiding this comment.
The migration to Hugo has resulted in the loss of descriptive page titles that were previously provided in the Jekyll front matter. Currently, Hugo defaults to using the filename (e.g., "mmdblookup") as the title. You can restore the descriptive titles (and optionally provide shorter link titles for the navigation) using Hugo's cascade feature in the configuration file.
| [[cascade]] | |
| layout = "default" | |
| [[cascade]] | |
| layout = "default" | |
| [[cascade]] | |
| [cascade._target] | |
| path = "/_index.md" | |
| title = "libmaxminddb - a library for working with MaxMind DB files" | |
| linkTitle = "libmaxminddb" | |
| [[cascade]] | |
| [cascade._target] | |
| path = "/mmdblookup.md" | |
| title = "mmdblookup - a utility to look up an IP address in a MaxMind DB file" | |
| linkTitle = "mmdblookup" |
| <meta charset="utf-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
| {{- $title := or .Title .File.BaseFileName -}} | ||
| <title>{{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ $title }} | {{ .Site.Title }}{{ end }}</title> |
There was a problem hiding this comment.
To support descriptive titles for the home page (set via configuration or front matter), the title tag should check for .Title before falling back to .Site.Title.
| <title>{{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ $title }} | {{ .Site.Title }}{{ end }}</title> | |
| <title>{{ if .IsHome }}{{ or .Title .Site.Title }}{{ else }}{{ $title }} | {{ .Site.Title }}{{ end }}</title> |
| <a href="{{ .Site.Home.RelPermalink }}"{{ if .IsHome }} class="active"{{ end }}>{{ .Site.Title }}</a> | ||
| {{ range .Site.RegularPages }} | ||
| <a href="{{ .RelPermalink }}"{{ if eq $.RelPermalink .RelPermalink }} class="active"{{ end }}>{{ or .Title .File.BaseFileName }}</a> | ||
| {{ end }} |
There was a problem hiding this comment.
Using .LinkTitle in the navigation allows for shorter labels in the pill nav while maintaining descriptive titles for the browser tab. This works in conjunction with the cascade settings in hugo.toml.
| <a href="{{ .Site.Home.RelPermalink }}"{{ if .IsHome }} class="active"{{ end }}>{{ .Site.Title }}</a> | |
| {{ range .Site.RegularPages }} | |
| <a href="{{ .RelPermalink }}"{{ if eq $.RelPermalink .RelPermalink }} class="active"{{ end }}>{{ or .Title .File.BaseFileName }}</a> | |
| {{ end }} | |
| <a href="{{ .Site.Home.RelPermalink }}"{{ if .IsHome }} class="active"{{ end }}>{{ or .Site.Home.LinkTitle .Site.Title }}</a> | |
| {{ range .Site.RegularPages }} | |
| <a href="{{ .RelPermalink }}"{{ if eq $.RelPermalink .RelPermalink }} class="active"{{ end }}>{{ or .LinkTitle .Title .File.BaseFileName }}</a> | |
| {{ end }} |
| ] | ||
|
|
||
| [tools] | ||
| hugo = "latest" |
There was a problem hiding this comment.
It is recommended to pin the Hugo version to a specific version (e.g., the one currently in the lock file) to ensure build reproducibility across different environments and CI. Using latest can lead to unexpected build failures if a new version of Hugo introduces breaking changes.
| hugo = "latest" | |
| hugo = "0.161.1" |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request migrates the documentation site from Jekyll to Hugo, introducing a new Hugo configuration, base templates, and styling. The release.sh script was simplified by removing the manual documentation generation and deployment logic. Feedback suggests restoring the version information in the documentation which was lost during the migration and improving the home page title for better SEO and clarity.
|
|
||
| git commit -m "Updated for $version" -a | ||
|
|
||
| read -r -e -p "Push to origin? (y/n) " should_push |
There was a problem hiding this comment.
The migration to Hugo removes the logic that previously injected the library version into the documentation site. In the Jekyll setup, release.sh added a version field to the front matter. Since the new Hugo site mounts raw markdown files from ../doc/, this version information is no longer present in the rendered site. Consider passing the version as a Hugo parameter or environment variable during the build process in GitHub Actions and updating the template to display it.
| <meta charset="utf-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
| {{- $title := or .Title .File.BaseFileName -}} | ||
| <title>{{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ $title }} | {{ .Site.Title }}{{ end }}</title> |
There was a problem hiding this comment.
The home page title is currently set to the site title ("libmaxminddb"), which is less descriptive than the previous Jekyll title ("libmaxminddb - a library for working with MaxMind DB files"). This can affect SEO and browser tab clarity. Consider using the more descriptive title for the home page.
| <title>{{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ $title }} | {{ .Site.Title }}{{ end }}</title> | |
| <title>{{ if .IsHome }}libmaxminddb - a library for working with MaxMind DB files{{ else }}{{ $title }} | {{ .Site.Title }}{{ end }}</title> |
Build with `mise run build-docs`, preview with `mise run serve-docs`. The site mounts the existing `doc/libmaxminddb.md` and `doc/mmdblookup.md` as Hugo content so the source of truth stays in one place. A small pill nav lets readers move between the two pages. CSS is inlined in the layout template — no external dependencies. Same Charter serif + forest-green design as the MaxMind-DB spec site. For STF-448. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Deploys the Hugo docs site on push to main. Uses the same mise-action pattern as PR #221. All actions are SHA-pinned. After merge, the Pages source needs to flip from "Deploy from a branch" (gh-pages) to "GitHub Actions" — handled in the mm_website Terraform PR. The legacy gh-pages branch can then be deleted. For STF-448. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The release script no longer needs to clone the gh-pages branch and regenerate Jekyll index/mmdblookup pages — the new Hugo workflow on main owns the docs site, and the doc/*.md files are now mounted as content directly. There is no versioned doc tree on gh-pages to preserve for this repo. For STF-448. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| @@ -0,0 +1,17 @@ | |||
| title = "libmaxminddb" | |||
There was a problem hiding this comment.
From Claude. Not sure if it matters if it's right:
- URL path break. Old Jekyll used permalink: /:title.html → mmdblookup.html. Hugo pretty URLs → /mmdblookup/. External links (forums, SO, blogs) to mmdblookup.html will 404.
Fix: set permalinks in hugo.toml or add aliases frontmatter on each page.
There was a problem hiding this comment.
| @@ -0,0 +1,17 @@ | |||
| title = "libmaxminddb" | |||
| disableKinds = ["taxonomy"] | |||
There was a problem hiding this comment.
Same feedback as on geoipupdate PR.
`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>
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 migrates the project's documentation system from a manual shell script process to a Hugo-based static site generator. The changes include removing legacy documentation generation from the release script, adding Hugo configuration and layouts, and updating the project's tool configuration to include Hugo and documentation-related tasks. A review comment identified a bug in the Hugo template logic where variable scoping prevented the correct assignment of page titles; a simplified approach using the 'or' function was suggested to resolve this.
`.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>
The old Jekyll site used `permalink: /:title.html` and served pages at `/mmdblookup.html`. Hugo's default pretty URLs would emit `/mmdblookup/`, breaking existing external links to the old paths. Set `uglyURLs = true` so Hugo writes `.html` suffixes for non-home pages, matching the old behavior exactly. 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 migrates the documentation generation process from a manual shell script in release.sh to a Hugo-based static site generator. It introduces a new docs directory containing Hugo configurations, layout templates, and CSS, while updating project tooling via mise to include Hugo tasks. Review feedback points out that uglyURLs should be disabled to maintain standard directory-style URL structures and suggests inlining the CSS to align with the PR's stated goals and optimize performance.
| @@ -0,0 +1,18 @@ | |||
| title = "libmaxminddb" | |||
| uglyURLs = true | |||
There was a problem hiding this comment.
The uglyURLs = true setting causes Hugo to generate files like mmdblookup.html instead of the directory-style structure (mmdblookup/index.html) expected by the test plan and mentioned in the PR description. To maintain the desired URL structure and match the test plan, this should be set to false (which is the default).
| uglyURLs = true | |
| uglyURLs = false |
There was a problem hiding this comment.
The uglyURLs = true setting is deliberate — the pre-migration Jekyll site served mmdblookup.html (the URL pattern documented in external references and search-engine indexed). Switching to Hugo's pretty-URL form (mmdblookup/) would 404 those existing links. This is preserving backward compatibility for libmaxminddb specifically.
(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.
The PR description states that "All CSS is now inlined in the layout template", but the current implementation uses a <link> tag to an external stylesheet. To actually inline the CSS as described and avoid an extra network request, you can use Hugo's .Content property within a <style> tag.
{{- with resources.Get "css/main.css" | minify -}}
<style>{{ .Content | safeCSS }}</style>
{{- end -}}There was a problem hiding this comment.
The PR description is stale — externalizing the CSS in round 9 was a deliberate choice on top of the earlier inlined form, made to enable browser caching of the stylesheet across pages on the docs site. The code is doing what we want; we'll update the PR description to reflect the current state.
(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>
Summary
Migrates the docs site from Jekyll on
gh-pagesto a Hugo build deployedvia GitHub Actions. All CSS is now inlined in the layout template — no
external CDN dependencies.
docs/onmainand mounts the existingdoc/libmaxminddb.mdanddoc/mmdblookup.mdas content, keeping thesource of truth in one place
two docs
.github/workflows/pages.ymlbuilds withmise run build-docsanddeploys via the GitHub Actions Pages environment
dev-bin/release.shno longer clonesgh-pagesor regenerates theindex/mmdblookup Jekyll pages
Same design as MaxMind-DB PR #221: Charter serif body text, forest-green
accent on field-name headings, hover
#anchor links.Preview locally with
mise run serve-docs.For STF-448.
Post-merge steps
mm_websiteto switch Pages source fromgh-pagesto GitHub Actionshttps://maxmind.github.io/libmaxminddb/mmdblookup/
gh-pagesbranchTest plan
mise run build-docssucceeds with no warningsindex.htmlandmmdblookup/index.htmlrender with correcttitles and working pill-nav
grep -r static-gh docs/returns nothingmain)🤖 Generated with Claude Code