# Add flag to suppress id=xxxx in generated H1..6 tags

**URL:** <https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748>\
**Category:** feature\
**Created:** [February 19, 2015, 4:31pm UTC](https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748 "2015-02-19T16:31:47Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxime\_michel](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@maxime\_michel](https://discourse.gohugo.io/u/maxime_michel)\
**Post date:** [February 19, 2015, 4:31pm UTC](https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748/1 "2015-02-19T16:31:47Z")

</div>

Hi, Hugo’s terrific, thanks to everybody who has participated in building it. There’s one thing I would like to do but haven’t found an option for: remove TOC tags if I decide to not use them. I was thinking that an option such as --disableRSS could be nice, does that sound like a good idea to you? It’s a detail, really, but Hugo is good at removing the bloat (I’m currently converting a WP site to it) that I find it a pity to see those extra tags in my code when I don’t need them.

Maxime

---

<div class="post-metadata">

**Author:** ![michael\_henderson](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/michael_henderson/32/10490_2.png) [@michael\_henderson](https://discourse.gohugo.io/u/michael_henderson)\
**Post date:** [February 19, 2015, 4:36pm UTC](https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748/2 "2015-02-19T16:36:24Z")

</div>

I’m not following. If you don’t include `{{ .TableOfContents }}` in your template, Hugo won’t generate the TOC. Are you referring to something different?

---

<div class="post-metadata">

**Author:** ![maxime\_michel](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@maxime\_michel](https://discourse.gohugo.io/u/maxime_michel)\
**Post date:** [February 19, 2015, 4:50pm UTC](https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748/3 "2015-02-19T16:50:51Z")

</div>

Yes, to the `id="toc_0"` tags generated in my header tags, actually.

---

<div class="post-metadata">

**Author:** ![michael\_henderson](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/michael_henderson/32/10490_2.png) [@michael\_henderson](https://discourse.gohugo.io/u/michael_henderson)\
**Post date:** [February 19, 2015, 4:54pm UTC](https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748/4 "2015-02-19T16:54:14Z")

</div>

Which layout are you using? And is this in the generated HTML or XML?

---

<div class="post-metadata">

**Author:** ![maxime\_michel](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@maxime\_michel](https://discourse.gohugo.io/u/maxime_michel)\
**Post date:** [February 19, 2015, 4:58pm UTC](https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748/5 "2015-02-19T16:58:50Z")

</div>

This comes in the HTML tags. I use `layouts/_default/single.html` and this happens on two separate Hugo websites.

---

<div class="post-metadata">

**Author:** ![michael\_henderson](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/michael_henderson/32/10490_2.png) [@michael\_henderson](https://discourse.gohugo.io/u/michael_henderson)\
**Post date:** [February 19, 2015, 5:03pm UTC](https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748/6 "2015-02-19T17:03:00Z")

</div>

Can you post the snippet that generates the tags? I’m not seeing that `toc_0` in my HTML, so I must be doing something differently than you.

---

<div class="post-metadata">

**Author:** ![maxime\_michel](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@maxime\_michel](https://discourse.gohugo.io/u/maxime_michel)\
**Post date:** [February 19, 2015, 5:07pm UTC](https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748/7 "2015-02-19T17:07:52Z")

</div>

- layouts/\_default/single.html: `{{ .Content }}`
- content/post.md: `## test title`
- HTML: `<h2 id="toc_0">test title</h2>`

---

<div class="post-metadata">

**Author:** ![michael\_henderson](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/michael_henderson/32/10490_2.png) [@michael\_henderson](https://discourse.gohugo.io/u/michael_henderson)\
**Post date:** [February 19, 2015, 5:12pm UTC](https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748/8 "2015-02-19T17:12:20Z")

</div>

Ok. You must be using version 0.12. With v0.13, the id is very different, that’s what confused me.

Content:

```auto
# test
## test
### test
## test
# test
## test

```

HTML:

```auto
<h1 id="test:4108045d631e1ffc0a8f9e461e342847">test</h1>

<h2 id="test-1:4108045d631e1ffc0a8f9e461e342847">test</h2>

<h3 id="test-2:4108045d631e1ffc0a8f9e461e342847">test</h3>

<h2 id="test-3:4108045d631e1ffc0a8f9e461e342847">test</h2>

<h1 id="test-4:4108045d631e1ffc0a8f9e461e342847">test</h1>

<h2 id="test-5:4108045d631e1ffc0a8f9e461e342847">test</h2>

```

---

<div class="post-metadata">

**Author:** ![maxime\_michel](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@maxime\_michel](https://discourse.gohugo.io/u/maxime_michel)\
**Post date:** [February 19, 2015, 5:15pm UTC](https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748/9 "2015-02-19T17:15:03Z")

</div>

Yes, I am using the latest stable. But what is your opinion on adding an option to remove those extra tags when unneeded? I feel like this feature wouldn’t be worth the trouble of writing it but perhaps somebody has a different opinion and would like to see this as well.

---

<div class="post-metadata">

**Author:** ![michael\_henderson](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/michael_henderson/32/10490_2.png) [@michael\_henderson](https://discourse.gohugo.io/u/michael_henderson)\
**Post date:** [February 19, 2015, 5:25pm UTC](https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748/10 "2015-02-19T17:25:58Z")

</div>

The `id` gets added to any heading in the content, so it’s not related to the `.TableOfContents` variable. That’s what the reference to `TOC` brought to mind. So, it could use a name that’s closer to the functionality.

I agree that it adds a little clutter to the HTML (especially with that new fingerprint), but I hadn’t even noticed it until after you pointed it out (even then, it took a couple of tries to actually see it). If it generated a different `id` each time I ran Hugo, then it would cause unnecessary (and unwanted) changes that would have to be pushed up. But if it’s the same, it doesn’t matter either way to me, especially since I’m not running any JQuery to manipulate the DOM based on `id`.

---

<div class="post-metadata">

**Author:** ![maxime\_michel](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@maxime\_michel](https://discourse.gohugo.io/u/maxime_michel)\
**Post date:** [February 19, 2015, 5:31pm UTC](https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748/11 "2015-02-19T17:31:21Z")

</div>

Sorry for the confusion, I thought of --disableTOC because of the way Hugo 0.12 names those ids (`toc_0`).

---

<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:** [February 19, 2015, 7:12pm UTC](https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748/12 "2015-02-19T19:12:54Z")

</div>

In 0.13 you can use plainIdAnchors

See

[https://github.com/spf13/hugo/blob/master/docs/content/overview/configuration.md](https://github.com/spf13/hugo/blob/master/docs/content/overview/configuration.md)

---

<div class="post-metadata">

**Author:** ![bguiz](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@bguiz](https://discourse.gohugo.io/u/bguiz)\
**Post date:** [February 22, 2015, 11:12pm UTC](https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748/13 "2015-02-22T23:12:11Z")

</div>

On a somewhat related note, I am not the biggest fan of IDs for header tags beiong generated with a hash, like this:

> [@michael\_henderson](#):
>
> \<h1 id=“test:4108045d631e1ffc0a8f9e461e342847”\>test\</h1\>

I would much rather have a predictable one like this,  
for the purposes of easily creating links from elsewhere in the same page,  
and also for comsemtiuc reasons:

\<h1 id=“test”\>test\</h1\>

I understand that the reason that hashes are added is to ensure that each one has a unique ID. However, I am wil;ling to manually ensure that all headings on a page are unique myself.

Is there currenlty an option to disable adding hashes?

Thanks

---

<div class="post-metadata">

**Author:** ![michael\_henderson](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/michael_henderson/32/10490_2.png) [@michael\_henderson](https://discourse.gohugo.io/u/michael_henderson)\
**Post date:** [February 22, 2015, 11:14pm UTC](https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748/14 "2015-02-22T23:14:35Z")

</div>

> [@bguiz](#):
>
> Is there currenlty an option to disable adding hashes?

In v0.13, you can add a flag for BlackFriday (the Markdown engine) to your `config.toml` file:

```auto
[blackfriday]
  plainIdAnchors = true

```

Before:

```auto
<h1 id="h1:f066022a5cd7e2eba28340b66795b149">h1</h1>
<h2 id="h2:f066022a5cd7e2eba28340b66795b149">h2</h2>
<h3 id="h3:f066022a5cd7e2eba28340b66795b149">h3</h3>

```

After:

```auto
<h1 id="h1">h1</h1>
<h2 id="h2">h2</h2>
<h3 id="h3">h3</h3>

```

---

<div class="post-metadata">

**Author:** ![bguiz](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@bguiz](https://discourse.gohugo.io/u/bguiz)\
**Post date:** [February 23, 2015, 12:15am UTC](https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748/15 "2015-02-23T00:15:37Z")

</div>

Ah, thanks for that, I was not aware of this option! Pity that we need 0.13 for this though. I’m collaborating with others who jsut use the hugo binary, so they are stuckl with 0.12 for now.

See: [http://discuss.gohugo.io/t/release-cycle/727/3?u=bguiz](http://discuss.gohugo.io/t/release-cycle/727/3?u=bguiz)

---

<div class="post-metadata">

**Author:** ![michael\_henderson](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/michael_henderson/32/10490_2.png) [@michael\_henderson](https://discourse.gohugo.io/u/michael_henderson)\
**Post date:** [February 23, 2015, 12:19am UTC](https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748/16 "2015-02-23T00:19:31Z")

</div>

@bgulz The v0.13 binaries are up on the web site - [https://github.com/spf13/hugo/releases](https://github.com/spf13/hugo/releases).

---

<div class="post-metadata">

**Author:** ![Matthew\_Dolman](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/matthew_dolman/32/11483_2.png) [@Matthew\_Dolman](https://discourse.gohugo.io/u/Matthew_Dolman)\
**Post date:** [January 29, 2016, 3:35am UTC](https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748/17 "2016-01-29T03:35:49Z")

</div>

If anyone is struggling with this post v0.15 it’s because they have become case sensitive and now you need to use: plainIDAnchors

---

<div class="post-metadata">

**Author:** ![thepian](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/thepian/32/1798_2.png) [@thepian](https://discourse.gohugo.io/u/thepian)\
**Post date:** [July 3, 2016, 9:36pm UTC](https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748/18 "2016-07-03T21:36:04Z")

</div>

This is an odd feature to have by default. I can understand that for blog post headings you would want IDs, but for everything it’s quite strange.

It makes the generated HTML constantly change by default which messes with SVN history. If you use the plain option it means that all headings get default IDs that might clash with other things on the page. That seems error-prone to me.

Can it be configured to only apply to certain headings. For instance h1/h2. Then at least you can use lower level ones to avoid it.

---

<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:** [July 3, 2016, 9:52pm UTC](https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748/19 "2016-07-03T21:52:10Z")

</div>

In 0.16 it is default off.

---

<div class="post-metadata">

**Author:** ![frank](https://avatars.discourse-cdn.com/v4/letter/f/3d9bf3/32.png) [@frank](https://discourse.gohugo.io/u/frank)\
**Post date:** [March 14, 2017, 9:47am UTC](https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748/20 "2017-03-14T09:47:30Z")

</div>

I use version 0.19. I have very long header texts. And each such text is rendered as Id. That is nonsensical.

the plainIDAnchors setting does not change this and by its description does not say that it would change this behavior.

[Next page](https://discourse.gohugo.io/t/add-flag-to-suppress-id-xxxx-in-generated-h1-6-tags/748.md?page=2)
