Skipping page building, depending on environment config?

Hey there,

I’m using different environment configs that I specify with -e and I would like to have pages that are only available on a specific environment. I’ve found people asking similar questions, however, I don’t see the replies answering this specific question.

Any help appreciated!

Let’s say you have a section titled “internal” that you don’t want published when your environment is production:

config
├── _default/
│   └── config.toml
└── production/
    └── config.toml

config/production/config.toml

[[cascade]]
  [cascade._build]
    render = "never"
    list = "never"
    publishResources = false
  [cascade._target]
    path = '/internal/**'

References:

2 Likes

@jmooring thank you very much for this! Is there any way that wouldn’t require prefixing the posts with a specific path? E.g. by setting a flag inside the posts themselves?

I thought of something similar like draft: true, only that it could specify the environment for which they are intended. That would make it possible to dynamically enable/disable posts for individual environments.

Let’s say you had this structure:

content/
├── books/
│   ├── book-1.md
│   ├── book-2.md
│   └── book-3.md
└── films/
    ├── film-1.md
    ├── film-2.md
    └── film-3.md

And you wanted to exclude book-2 and film-3 from your “production” environment builds. The cascade target keywords are glob patterns, allowing you to do this:

[[cascade]]
  [cascade._build]
    render = "never"
    list = "never"
    publishResources = false
  [cascade._target]
    kind = 'page'
    path = '{**book-2*,**film-3*}'

No. You cannot set a build option that is keyed to a particular environment.

Even if I could do that, I probably wouldn’t. I think it’s easier to track this stuff centrally in site configuration.

1 Like

Thank you very much!

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.