I am completely new to statically site generation (SSG). I have looked through the documentation, but I am not able to completely ascertain whether or not this is possible within the Hugo ecosystem or within scope of SSG.
Problem
As a writer, I may edit an existing page/post/piece for either clarity, fix typos, provide correction, or even complete redaction (in rare cases). For each of these actions (1...n), I want to capture each revision and make them available to the reader.
Case 0: Writer wants to make N edits to a published page
Given
Project initialized with hugo new project blog
Project revisioned with git
Post created with hugo new content content/posts/expose-on-corruption.md at 2026-07-19T12:00:00-00:00
Initial post committed to git repository by author at 2026-07-19T12:00:00-00:00 with SHA-1 of aaaa...
Post is not marked as a draft
When
Author makes an edit at 2026-07-19T13:01:00-00:00, commits changes, SHA-1 of bbbb...
edit: title changed to Expose on Corrupt Government Branch
Author makes an edit at 2026-07-19T13:30:00-00:00, commits changes, SHA-1 of cccc...
edit: add key figures, events, update timeline
Author makes an edit at 2026-07-19T15:00:00-00:00, commits changes, SHA-1 of dddd...
edit: update sources
Then
hugo should generate 4 pages of the same post and provide stable URLs for each revision
You can do this with a content adapter that queries the GitHub API. Two API approaches:
Get a list of the last N commits by querying the GitHub API, then query the GitHub API for each commit to get the content of the given file path.
Get a list of the last N commits using the GitInfo.Ancestors method, then query the GitHub API for each commit to get the content of the given file path.
The result of the file query looks like this, where the content is base64 encoded.
I’m familiar with the GitHub API; presumably you can do the same with GitLab, Bitbucket, etc. Regardless of approach, the number of API calls may exceed the rate limit in the absence of a personal access token. Note that, in its default configuration, Hugo indefinitely caches the result of each API call, reducing the number of calls during subsequent builds.
A separate page for each revision would not contain any details about the change itself. It seems like a diff or blame output (see previous comment) would be much more useful.
Also note that, given two commits and a file path, you can show a GitHub side-by-side comparison with something like this:
If you want to avoid API calls and don’t want to provide links to GitHub UI’s, use @Welsh’s approach (a pre-build script) in conjunction with a content adapter.
I don’t use content adapter, because I didn’t know them when I code
But it’s a feature I want to implement.
I just want to explain my need which leads me not ot use API. I use the version info in order to display the evolution of a post through the commit messages, in the footer of the post.
As I use this snippet in many projects (private and professional), I just wanted a solution which is not dependant of the repositiory (Github, Gitlab…).