Hello, I have some .md pages that may occur at all levels in a content folder, alongside regular content.
I want these pages to act like regular pages only in “development,” but not in “production.”
I am reviewing these pages in the documentation but still can not find the answer.
Edit: I believe I could add specific front-matter to these pages to help (type: "development"), but this would mean adding a filter to many list functions across multiple templates.
I think I was hoping for an option like
_build:
list: "development"
render: "development"
Solved
Update: I marked this as the solution for three reasons.
It currently works.
It would transition easily to ideal solution if issue mentioned is resolved.
Avoids maintaining a separate structure. There was a core requirement to have the internal pages alongside existing content.
Thanks, I understand I can have a custom config for staging or production. But I don’t understand how I would tell hugo not to bother with some pages in production only.
My content folder exists with many section and subsections - nested leaf and branch bundles. Most files I want in production. However, some files which exist in parallel to production content files I only want in development.
The example above works with regular content pages, not leaf or branch bundles. You could consider including the string “_skip_” somewhere in the path other than the file name, but… yuck.
Good point, yes, I can achieve a similar outcome by using drafts or date-hacking with --buildsFuture. However, I would then lose the ability to use drafts (or dates) for their intended purpose.
Thinking more about this, targeting pages based on type in front matter is not a good idea, at least for your particular use case—it would preclude you from using type to control which layout is used.
The right way is to target based on a custom front matter parameter, which may not be possible—it seems like front matter parameters are not available until after we cascade front matter parameters down from site configuration (chicken/egg).
I will edit #10936, but don’t be surprised if this is closed as either not possible or too expensive (time and/or performance).
As for what’s possible today, mounting an additional content directory based on environment (as described above) seems like the cleanest approach.