[SOLVED] Unexpected token when adding ENV variable

My code in config.toml

HUGO_ENV = "development"
########################### DEV
    {{ if eq (getenv "HUGO_ENV") "development" }}
    <!-- dev stuff here -->


    baseURL = "localhost:1313"
    title = "LOCAL: "

    {{ end }}
########################### STAGING

and I get “Error: While parsing config: (17, 5): unexpected token” for the first curly bracket in the if statement. Any advice from you old timers?

Also, is my syntax correct in adding the environment variable:

HUGO_ENV = “development”?

Thanks!

You cannot use Go Template syntax inside your configuration file.

What you can do is have two distinct configuration file and call the right one depending on your environment:
hugo —config "config.prod.yaml"

It’s not in the doc yet but you can even use two configuration files and they’ll be merged so you can have a default configuration file and a small layer one for your environments.

hugo —config "config.base.yaml,config.prod.yaml"

1 Like

OK. Thanks @regis I’ll split them as you recommend.