Deploy docs site with Hugo via GitHub Actions#702
Conversation
Build with `mise run build-docs`, preview with `mise run serve-docs`. The site mounts the existing `README.md` as the home page so the source of truth stays in one place. A small pill nav links from Overview to the versioned API documentation that lives on the `gh-pages` branch under `doc/latest/`. 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. The workflow builds the site with `mise run build-docs` and pushes the rendered output onto the existing `gh-pages` branch with `keep_files: true` — that preserves every `/doc/vX.Y.Z/` Javadoc subtree exactly as the release script publishes them. Pages keeps deploying from `gh-pages`, so no Terraform change is needed for this repo. All actions are SHA-pinned. For STF-448. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Hugo on `main` now owns the Pages index, so the release script no longer needs to write a Jekyll front-matter wrapper around README.md on the gh-pages branch. The Javadoc-publishing block that creates `doc/$tag/` and updates the `doc/latest` symlink is unchanged — that versioned tree continues to live on gh-pages and is preserved by the new workflow's `keep_files: true`. For STF-448. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request transitions the project's documentation generation from a manual script to Hugo, introducing a new Hugo configuration, layouts, and mise tasks for building and serving the site. The review feedback suggests enhancing the robustness of the HTML templates by handling potential null file objects in the page title and using absolute URLs for links to external API documentation. Additionally, it is recommended to pin the Hugo version in the mise configuration rather than using the 'latest' tag to ensure environment consistency.
| <head> | ||
| <meta charset="utf-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
| <title>{{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ or .Title .File.BaseFileName }} | {{ .Site.Title }}{{ end }}</title> |
There was a problem hiding this comment.
The fallback logic or .Title .File.BaseFileName might fail if .File is nil, which can happen for certain virtual pages in Hugo. While all current pages are file-backed, it's safer to use the with statement or check for .File existence to avoid potential build errors in the future.
| <title>{{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ or .Title .File.BaseFileName }} | {{ .Site.Title }}{{ end }}</title> | |
| <title>{{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }}{{ else }}{{ with .File }}{{ .BaseFileName }}{{ end }}{{ end }} | {{ .Site.Title }}{{ end }}</title> |
| <body> | ||
| <nav class="page-nav"> | ||
| <a href="{{ .Site.Home.RelPermalink }}"{{ if .IsHome }} class="active"{{ end }}>Overview</a> | ||
| <a href="{{ "doc/latest/" | relURL }}">API documentation</a> |
There was a problem hiding this comment.
Using relURL for a path that is not managed by Hugo (the Javadocs are generated by Maven and pushed directly to gh-pages) might lead to incorrect links if the baseURL in hugo.toml is not perfectly aligned with the deployment environment. Since the Javadocs are at a known path relative to the site root, using absURL or ensuring the path starts with a leading slash (if baseURL includes the subpath) is often more robust.
| <a href="{{ "doc/latest/" | relURL }}">API documentation</a> | |
| <a href="{{ "/doc/latest/" | absURL }}">API documentation</a> |
| ] | ||
|
|
||
| [tools] | ||
| hugo = "latest" |
There was a problem hiding this comment.
Summary
Migrates the Pages index from Jekyll on
gh-pagesto a Hugo build thatpublishes back onto
gh-pagesfrom GitHub Actions. All CSS is nowinlined in the layout template — no external CDN dependencies.
docs/onmainand mountsREADME.mdasthe home page; the source of truth stays in one place
/doc/latest/.github/workflows/pages.ymlbuilds withmise run build-docsandpushes to
gh-pagesviapeaceiris/actions-gh-pageswithkeep_files: true, so every/doc/vX.Y.Z/Javadoc subtree staysuntouched
dev-bin/release.shno longer regenerates the Jekyllindex.md;the Javadoc-publishing block that writes
doc/$tag/and updatesdoc/latestis unchangedSame design as MaxMind-DB PR #221: Charter serif body text,
forest-green accents, hover
#anchor links.Preview locally with
mise run serve-docs.For STF-448.
Post-merge steps
a sample https://maxmind.github.io/GeoIP2-java/doc/latest/ still
loads after the next workflow run
legacy Jekyll source (
_config.yml,_layouts/, therelease-generated
index.md,stylesheets/pygments.css,Gemfile*) from thegh-pagesbranch in a separate commitPages source stays on
gh-pages— no Terraform change for this repo.Test plan
mise run build-docssucceeds with no warnings<title>,<h1>, and pill nav are correctstatic-gh.maxmind.comreferences in the new sitemain)and
/doc/vX.Y.Z/subtrees are preserved🤖 Generated with Claude Code