How to generate 1 page (of many)

I have a working Hugo site. It has hundreds of pages. However there are times I just want to regenerate a single page.

I know that hugo is super fast, often rendering hundreds or thousands of pages per second. However in this case I’m trying to optimize a particular situation and the fastest I can regenerate this one particular page the better.

If the one page you wish to render has no references to, or dependencies on, other pages then you could do something like…

content/
├── posts/
│   ├── post-1.md  <-- we only want to render this page
│   ├── post-2.md
│   └── post-3.md
└── _index.md
config/
├── _default/
│   └── config.toml
└── one-page/
    └── config.toml

config/one-page/config.toml

disableKinds = ['home','section','taxonomy','term','404','RSS','sitemap']

[[module.mounts]]
source = 'content'
target = 'content'
includeFiles = ['/posts/post-1.md']

Then build the site with:

hugo -e one-page

result

public/
└── posts/
    └── post-1/
        └── index.html

But if this one page would normally contain references to other pages (related content, menu items that are attached to page references, etc.) the rendered page will be incomplete.

This may be supported by Hugo in the near future. See Add segments config + --renderSegments flag · Issue #10106 · gohugoio/hugo · GitHub