# Disable portions of content while developing

**URL:** <https://discourse.gohugo.io/t/disable-portions-of-content-while-developing/10860>\
**Category:** support\
**Created:** [March 5, 2018, 12:35pm UTC](https://discourse.gohugo.io/t/disable-portions-of-content-while-developing/10860 "2018-03-05T12:35:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mydoghasworms](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mydoghasworms/32/5330_2.png) [@mydoghasworms](https://discourse.gohugo.io/u/mydoghasworms)\
**Post date:** [March 5, 2018, 12:35pm UTC](https://discourse.gohugo.io/t/disable-portions-of-content-while-developing/10860/1 "2018-03-05T12:35:20Z")

</div>

Is there a way to disable/remove portions of my page while testing with `hugo server`?

While developing, I want to disable my site’s Google analytics and ads in my html template pages.

I was hoping this might be possible with some sort of conditional code you can add to the templates.

---

<div class="post-metadata">

**Author:** ![RickCogley](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rickcogley/32/10269_2.png) [@RickCogley](https://discourse.gohugo.io/u/RickCogley)\
**Post date:** [March 5, 2018, 12:50pm UTC](https://discourse.gohugo.io/t/disable-portions-of-content-while-developing/10860/2 "2018-03-05T12:50:11Z")

</div>

Yeah, something like:

> <https://github.com/RickCogley/RCC-Hugo2015/blob/master/layouts/partials/bodyend.html#L14>

---

<div class="post-metadata">

**Author:** ![mydoghasworms](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mydoghasworms/32/5330_2.png) [@mydoghasworms](https://discourse.gohugo.io/u/mydoghasworms)\
**Post date:** [March 5, 2018, 2:33pm UTC](https://discourse.gohugo.io/t/disable-portions-of-content-while-developing/10860/3 "2018-03-05T14:33:24Z")

</div>

Too nice! Thank you very much.

👌

---

<div class="post-metadata">

**Author:** ![mydoghasworms](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mydoghasworms/32/5330_2.png) [@mydoghasworms](https://discourse.gohugo.io/u/mydoghasworms)\
**Post date:** [March 7, 2018, 9:32am UTC](https://discourse.gohugo.io/t/disable-portions-of-content-while-developing/10860/4 "2018-03-07T09:32:48Z")

</div>

Is there a way to differentiate based on the fact that you are running `hugo server` instead of just the `-D` flag?

In other words, I want to view the site with `hugo server`, just as it will look (without drafts) in the live environment, but I still want to disable analytics, ads etc.

---

<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:** [March 7, 2018, 10:48am UTC](https://discourse.gohugo.io/t/disable-portions-of-content-while-developing/10860/5 "2018-03-07T10:48:58Z")

</div>

No, but the common way of doing this is to check a user defined environment variable:

```auto
{{ if eq (getenv "env") "prod" }}
// include google analytics
{{ end }}

```

You need to then do:

```auto
HUGO_ENV=prod hugo 

```

When you publish your site.

---

<div class="post-metadata">

**Author:** ![mydoghasworms](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mydoghasworms/32/5330_2.png) [@mydoghasworms](https://discourse.gohugo.io/u/mydoghasworms)\
**Post date:** [March 7, 2018, 10:53am UTC](https://discourse.gohugo.io/t/disable-portions-of-content-while-developing/10860/6 "2018-03-07T10:53:16Z")

</div>

Thank you for the suggestion.

So this requires a change to a file somewhere. Problem for me is, I might forget and then publish the site without remembering to make that change…

Do you think this is worth a feature request? Some way to identify when the site is being shown under `hugo server`? Does it sound feasible?

---

<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:** [March 7, 2018, 11:02am UTC](https://discourse.gohugo.io/t/disable-portions-of-content-while-developing/10860/7 "2018-03-07T11:02:17Z")

</div>

> [@mydoghasworms](#):
>
> Does it sound feasible?

Yes, it is easy to add. Please create a new GitHub issue.

We’ve had a discussion about adding an `IsDev` flag or something, and that is harder to decide. But the `IsServer` is easy to answer.

---

<div class="post-metadata">

**Author:** ![mydoghasworms](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mydoghasworms/32/5330_2.png) [@mydoghasworms](https://discourse.gohugo.io/u/mydoghasworms)\
**Post date:** [March 7, 2018, 11:12am UTC](https://discourse.gohugo.io/t/disable-portions-of-content-while-developing/10860/8 "2018-03-07T11:12:35Z")

</div>

Thank you. Added [https://github.com/gohugoio/hugo/issues/4478](https://github.com/gohugoio/hugo/issues/4478)
