# Environment specific Build profiles

**URL:** <https://discourse.gohugo.io/t/environment-specific-build-profiles/6703>\
**Category:** support\
**Created:** [May 24, 2017, 1:03pm UTC](https://discourse.gohugo.io/t/environment-specific-build-profiles/6703 "2017-05-24T13:03:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bdot](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@bdot](https://discourse.gohugo.io/u/bdot)\
**Post date:** [May 24, 2017, 1:03pm UTC](https://discourse.gohugo.io/t/environment-specific-build-profiles/6703/1 "2017-05-24T13:03:42Z")

</div>

Hi Guys, Any idea if Hugo supports build profiles or something similar

I have few properties in json/yaml file and these are environment specific values. If I am running hugo locally, I want to use dev related props while it’s running in prod I want to use prod related properties. Just wondering if this is something possible with existing setup.

Thanks for your time.

---

<div class="post-metadata">

**Author:** ![Mikhail](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mikhail/32/1138_2.png) [@Mikhail](https://discourse.gohugo.io/u/Mikhail)\
**Post date:** [May 24, 2017, 1:11pm UTC](https://discourse.gohugo.io/t/environment-specific-build-profiles/6703/2 "2017-05-24T13:11:40Z")

</div>

> **[How to Exclude Google Analytics When Running Under Hugo Local Server](https://discourse.gohugo.io/t/how-to-exclude-google-analytics-when-running-under-hugo-local-server/6092/8)**
>
> This is what I do: {{ if eq (getenv "HUGO\_ENV") "production" }} {{ template "\_internal/google\_analytics\_async.html" . }} {{ end }} which of course, means in production, you set your environment to production. On the command line it looks...

---

<div class="post-metadata">

**Author:** ![rhewitt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rhewitt/32/332_2.png) [@rhewitt](https://discourse.gohugo.io/u/rhewitt)\
**Post date:** [May 24, 2017, 1:40pm UTC](https://discourse.gohugo.io/t/environment-specific-build-profiles/6703/3 "2017-05-24T13:40:06Z")

</div>

Use multiple config files `config.dev.yml` vs. `config.stage.yml` vs. `config.prod.yml`.

Then when you run hugo on the command line use the config flag:

```auto
hugo --config=site/config.dev.yml

```

I use node as a build system with hugo rather than using different config files, but it achieves the same goal. You can see a few different `npm scripts` related to hugo in my [package.json](https://github.com/USFWS/southeast/blob/295e121da0887e2a5d1760c79f0a320688cfd15b/package.json#L23-L25) file. Here’s my [hugo build script](https://github.com/USFWS/southeast/blob/master/build/hugo.js) which determines whether or not to build drafts, and the base URL to use when building the site.

---

<div class="post-metadata">

**Author:** ![bdot](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@bdot](https://discourse.gohugo.io/u/bdot)\
**Post date:** [May 29, 2017, 8:12am UTC](https://discourse.gohugo.io/t/environment-specific-build-profiles/6703/4 "2017-05-29T08:12:56Z")

</div>

Thanks @rhewitt @Mikhail . This helps.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [May 29, 2017, 8:10pm UTC](https://discourse.gohugo.io/t/environment-specific-build-profiles/6703/5 "2017-05-29T20:10:56Z")

</div>

You can also override specific settings via OS environment variables, which is super-useful if you are deploying from Netflify or some other CI.

```auto
HUGO_THEME=docdock hugo

```

All upper case, prefix with “HUGO\_”

---

<div class="post-metadata">

**Author:** ![anon34662560](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@anon34662560](https://discourse.gohugo.io/u/anon34662560)\
**Post date:** [June 10, 2017, 4:58am UTC](https://discourse.gohugo.io/t/environment-specific-build-profiles/6703/6 "2017-06-10T04:58:03Z")

</div>

> [@bdot](#):
>
> If I am running hugo locally, I want to use dev related props while it’s running in prod I want to use prod related properties.

As others have suggested, the `hugo` flags can be leveraged to produce different effects when built. Simply using flags gives you great control and helps you maintain a [Twelve-Factor App](https://12factor.net/config), which states about config:

> Apps sometimes store config as constants in the code. This is a violation of twelve-factor, which requires **strict separation of config from code**. Config varies substantially across deploys, code does not.

Like @rhewitt suggests you could use NPM scripts, which are really just a convenient way to run little bin scripts (usually written it bash or JS, but certainly not limited to them). [Composer](https://getcomposer.org) JSON files can run bin scripts as well. Or you could simply create a Makefile or Rakefile (plenty to borrow from Jekyll community there) and run flags using IoC pattern, which is very common.

Personally use a Rakefile to create an environment specific build file because and tools written in a number of different languages to build and deploy my Hugo site.

My best advice is to start small and build slowly as the need arises so you know what your getting and how it fits into your workflow. Leveraging existing tools can be great. But they also require maintenance and come with their own associated risks and benefits.

---

<div class="post-metadata">

**Author:** ![bdot](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@bdot](https://discourse.gohugo.io/u/bdot)\
**Post date:** [July 28, 2017, 4:53pm UTC](https://discourse.gohugo.io/t/environment-specific-build-profiles/6703/7 "2017-07-28T16:53:31Z")

</div>

Thanks @bep . This is interesting. Any idea how we can override params defined under “params” like below? Is there any notation for this?

```auto
[params]
   author = "test"

```

---

<div class="post-metadata">

**Author:** ![Mikhail](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mikhail/32/1138_2.png) [@Mikhail](https://discourse.gohugo.io/u/Mikhail)\
**Post date:** [July 30, 2017, 6:59am UTC](https://discourse.gohugo.io/t/environment-specific-build-profiles/6703/8 "2017-07-30T06:59:30Z")

</div>

You can do this easily in the template using the function [default](https://gohugo.io/functions/default/)

```auto
{{ default .Site.Params.author (Something that replaces) }}

```
