Prevent a page be rendered

Assuming I have a property like .Site.domain.

Now assuming I have several pages, like:

  1. page1/
    domains: [, ]
    # page1.
  2. page2/
    domains: [ ]
    # page2.
  3. page3/
    domains: [ ]
    # page3.

If I call now hugo I want that if just all pages are rendered where and in another call

How to do that in the sitemap is clear to me, but how to fully prevent hugo from creating the related pageX/index.html?

You can set Build Options in your frontmatter

Thanks @pamubay,

I’ve read this article already, but still have issues to apply this to my described problem. In my case the page should not define if it is rendered. I need to define from another global point if a page that meets a requirement is rendered or not.

Can you outline an example for that?

Unfortunately, that’s not possible in Hugo.

You can include/exclude by filename.

├── post
│   ├──
│   ├──
│   ├──
│   ├──
│   └──

Build the site, ignoring content with .a. in the filename:

HUGO_IGNOREFILES=[\\.a\\.] hugo --cleanDestinationDir

Build the site, ignoring content with .b. in the filename:

HUGO_IGNOREFILES=[\\.b\\.] hugo --cleanDestinationDir

Build the site, ignoring content with either .a. or .b. in the filename:

HUGO_IGNOREFILES=[\\.a\\.,\\.b\\.] hugo --cleanDestinationDir

To avoid creating URLs such as /post/post-1.a/ you will want to configure a permalink pattern for each content type. Something like

post = "/:sections/:slug"

Finally, setting the configuration value HUGO_IGNOREFILES on the command line does not define the configuration value; it changes the existing value. Or to put it another way, you cannot change the ignoreFiles configuration option from the command line unless you first define it in the configuration file.

ignoreFiles = []

Remember, with the TOML syntax this must appear before tables and arrays of tables.

One more thing: the --cleanDestinationDir option does not work unless you have a static directory. This is a known issue:

What you can do is to put build options in the cascade section of your home page – and only target the pages you want to “not render”: