Need help with build: render: target: environment in single .md files

I’m trying to apply the following to several individual markdown files.

While render and list seem to be working properly, my environment setting seems to have no impact. I have tested with hugo server and various versions of hugo server --environment [insert value]

The goal is to build these pages locally for testing/internal reference but not wanting them to be published on the production server.

I’ve read over documentation, and do not have any config related to build.

Any suggestions would be fantastic, there may be something simple I’m looking over.

build: 
    render: never
    list: never
    target:
        environment: production   

Thanks in advance and hats off to the development team, Hugo continues to be a massive win!

How do you build and deploy your site in production?

Site is built on Netlify with a hugo server --minify command. Does this answer the question?

I do have some IGNOREFILES parameters set for the Netlify environment via netlify.toml which is easy when based on an entire directory, but for these purposes I need some individual controls per .md file

You should build it with the “hugo” command, not “hugo server”.

https://gohugo.io/host-and-deploy/host-on-netlify/#step-1

I apologize, on Netlify I am not using server

When testing locally is using server impacting the production environment?

I’m not sure I understand your question, but…

  1. Make sure you understand this: https://gohugo.io/quick-reference/glossary/#environment
  2. If you are testing locally, and switching back and forth between publishing all and publishing some, remember to clear your public directory before each test. On Netlify you don’t have to worry about that because each build starts with a clean slate.

Also, where is this?

I’ll start there, thank you

This is located in a single markdown file. content/about/helpers.md in this instance.

The goal is simply to reference this when building locally, and not have it publish to Netlify, but there are a number of various .md files i’d like to apply this to.

I admit my knowledge of environment building is limited.

I’m sorry, I read this too fast.

The target keyword is for cascade, not for build.

So you would need this in your site config.

[[cascade]]
  [cascade.build]
    render = 'never'
    list   = 'never'
  [cascade.target]
    environment = 'production'
    path        = '/about/helpers'
1 Like

Ahhhhhhh, yes. Ok, that’s very helpful.

I definitely overlooked that about target, thank you.

If you need to omit multiple page, you can use something like:

path        = '{/about/helpers,/products/soap}'

The value is a glob pattern.

1 Like

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