# Do not index certain pages

**URL:** https://discourse.gohugo.io/t/do-not-index-certain-pages/26596
**Category:** support
**Created:** [June 30, 2020, 6:44am UTC](https://discourse.gohugo.io/t/do-not-index-certain-pages/26596 "2020-06-30T06:44:38Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![hendry](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hendry/32/7037_2.png) [@hendry](https://discourse.gohugo.io/u/hendry)
#### Post date: [June 30, 2020, 6:44am UTC](https://discourse.gohugo.io/t/do-not-index-certain-pages/26596/1 "2020-06-30T06:44:38Z")

</div>

Hi! Say I have content that looks like

```auto
content/
├── 2020
│ └── first-blog.md
└── internal-boring-do-not-index
    └── ref.md

```

How do I prevent **internal-boring-do-not-index** from appearing in:

- index.xml
- sitemap.xml
- internal-boring-do-not-index/index.xml

I **don’t want to use robots.txt** because I don’t want to draw attention to this content.

Many thanks!

---

<div class="post-metadata">

### Author: ![martignoni](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/martignoni/32/5756_2.png) [@martignoni](https://discourse.gohugo.io/u/martignoni)
#### Post date: [June 30, 2020, 7:32am UTC](https://discourse.gohugo.io/t/do-not-index-certain-pages/26596/2 "2020-06-30T07:32:32Z")

</div>

I do this with a parameter in front matter:

```auto
---
title: This page will be excluded from sitemap
robotsdisallow: true
---

```

Then using such a construct in your template, e.g. `sitemap.xml`:

```auto
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
  xmlns:xhtml="http://www.w3.org/1999/xhtml">
  {{ range where .Site.RegularPages "Params.robotsdisallow" "!=" true }}
    ...
  {{ end }}
</urlset>

```

Live example here

> <https://github.com/moodlebox/moodlebox.net/blob/master/layouts/_default/sitemap.xml>

---

<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: [June 30, 2020, 7:47am UTC](https://discourse.gohugo.io/t/do-not-index-certain-pages/26596/3 "2020-06-30T07:47:09Z")

</div>

Also see

> **[Build Options](https://gohugo.io/content-management/build-options/#readout)**
>
> Build options help define how Hugo must treat a given page when building the site.

---

<div class="post-metadata">

### Author: ![hendry](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hendry/32/7037_2.png) [@hendry](https://discourse.gohugo.io/u/hendry)
#### Post date: [June 30, 2020, 8:49am UTC](https://discourse.gohugo.io/t/do-not-index-certain-pages/26596/4 "2020-06-30T08:49:20Z")

</div>

Really struggling to understand those confusing [build options](https://gohugo.io/content-management/build-options/#readout).

```
[hendry@t480s show]$ hugo version
Hugo Static Site Generator v0.73.0/extended linux/amd64 BuildDate: unknown
[hendry@t480s show]$ cat content/do-not/foo.md
---
title: Do no index me
_build:
  render: false
  list: never
  publishResources: false
---

Boo!
[hendry@t480s show]$ grep do-not public/index.xml
[hendry@t480s show]$ vim public/index.xml
[hendry@t480s show]$ grep not public/index.xml
[hendry@t480s show]$ grep not public/sitemap.xml
    <loc>http://example.org/do-not/</loc>

```

I’m probably better off creating a Go template.

---

<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: [June 30, 2020, 9:04am UTC](https://discourse.gohugo.io/t/do-not-index-certain-pages/26596/5 "2020-06-30T09:04:47Z")

</div>

> [@hendry](#):
>
> ` <loc>http://example.org/do-not/</loc>`

That is not the same URL as the one you “unlisted”.

---

<div class="post-metadata">

### Author: ![hendry](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hendry/32/7037_2.png) [@hendry](https://discourse.gohugo.io/u/hendry)
#### Post date: [June 30, 2020, 9:57am UTC](https://discourse.gohugo.io/t/do-not-index-certain-pages/26596/6 "2020-06-30T09:57:40Z")

</div>

> [@bep](#):
>
> That is not the same URL as the one you “unlisted”.

I’m sorry, Why? Because it’s a section?

---

<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: [June 30, 2020, 10:20am UTC](https://discourse.gohugo.io/t/do-not-index-certain-pages/26596/7 "2020-06-30T10:20:01Z")

</div>

> [@hendry](#):
>
> I’m sorry, Why? Because it’s a section?

Because it’s not where you foot the `_build` configuration. I’m not sure how to explain it differently.

---

<div class="post-metadata">

### Author: ![hendry](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hendry/32/7037_2.png) [@hendry](https://discourse.gohugo.io/u/hendry)
#### Post date: [July 1, 2020, 3:13am UTC](https://discourse.gohugo.io/t/do-not-index-certain-pages/26596/9 "2020-07-01T03:13:50Z")

</div>

Oh, so I need to use the \_index.md with \_build stanzas to exclude a section?

Did I understand correctly?

---

<div class="post-metadata">

### Author: ![hendry](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hendry/32/7037_2.png) [@hendry](https://discourse.gohugo.io/u/hendry)
#### Post date: [July 2, 2020, 9:40am UTC](https://discourse.gohugo.io/t/do-not-index-certain-pages/26596/10 "2020-07-02T09:40:04Z")

</div>

Thanks @martignoni … I ended up with

```auto
 ...
  {{ range .Data.Pages -}}
  {{- if or (eq .Section "services") (eq .Section "2020")}}
...

```

in my `layouts/_default/sitemap.xml`

---

<div class="post-metadata">

### Author: ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)
#### Post date: [July 4, 2020, 9:40am UTC](https://discourse.gohugo.io/t/do-not-index-certain-pages/26596/11 "2020-07-04T09:40:06Z")

</div>

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