# Hide content from single template

**URL:** <https://discourse.gohugo.io/t/hide-content-from-single-template/4239>\
**Category:** support\
**Created:** [October 5, 2016, 7:13pm UTC](https://discourse.gohugo.io/t/hide-content-from-single-template/4239 "2016-10-05T19:13:15Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![robsonsobral](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/robsonsobral/32/1628_2.png) [@robsonsobral](https://discourse.gohugo.io/u/robsonsobral)\
**Post date:** [October 5, 2016, 7:13pm UTC](https://discourse.gohugo.io/t/hide-content-from-single-template/4239/1 "2016-10-05T19:13:15Z")

</div>

Hi!

Is it possible to have content accessible only by the list template?

Thank you!

---

<div class="post-metadata">

**Author:** ![digitalcraftsman](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/digitalcraftsman/32/4142_2.png) [@digitalcraftsman](https://discourse.gohugo.io/u/digitalcraftsman)\
**Post date:** [October 6, 2016, 4:23pm UTC](https://discourse.gohugo.io/t/hide-content-from-single-template/4239/2 "2016-10-06T16:23:04Z")

</div>

I don’t think is possible with Hugo. It would be a bit complicated to define which content should be shown on what kind of template.

---

<div class="post-metadata">

**Author:** ![robsonsobral](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/robsonsobral/32/1628_2.png) [@robsonsobral](https://discourse.gohugo.io/u/robsonsobral)\
**Post date:** [October 6, 2016, 5:50pm UTC](https://discourse.gohugo.io/t/hide-content-from-single-template/4239/3 "2016-10-06T17:50:18Z")

</div>

I just found about the [ignoreFiles](https://github.com/spf13/hugo/issues/1189) setting, but I couldn’t test it yet.

---

<div class="post-metadata">

**Author:** ![robsonsobral](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/robsonsobral/32/1628_2.png) [@robsonsobral](https://discourse.gohugo.io/u/robsonsobral)\
**Post date:** [October 9, 2016, 12:47pm UTC](https://discourse.gohugo.io/t/hide-content-from-single-template/4239/4 "2016-10-09T12:47:22Z")

</div>

Well, I tested `ignoreFiles`. It hides the files for everything. I can’t even use `range` to read them. So… No way.

I gonna have to move everything to `data` directory.

Thanks.

---

<div class="post-metadata">

**Author:** ![robsonsobral](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/robsonsobral/32/1628_2.png) [@robsonsobral](https://discourse.gohugo.io/u/robsonsobral)\
**Post date:** [September 14, 2017, 8:45pm UTC](https://discourse.gohugo.io/t/hide-content-from-single-template/4239/5 "2017-09-14T20:45:54Z")

</div>

Maybe this can help somebody.

I ended setting `layout: none` on front matter.

---

<div class="post-metadata">

**Author:** ![Leo\_Merkel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/leo_merkel/32/3321_2.png) [@Leo\_Merkel](https://discourse.gohugo.io/u/Leo_Merkel)\
**Post date:** [September 15, 2017, 4:04pm UTC](https://discourse.gohugo.io/t/hide-content-from-single-template/4239/6 "2017-09-15T16:04:51Z")

</div>

What a great finding - very smart.

---

<div class="post-metadata">

**Author:** ![robsonsobral](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/robsonsobral/32/1628_2.png) [@robsonsobral](https://discourse.gohugo.io/u/robsonsobral)\
**Post date:** [September 15, 2017, 9:07pm UTC](https://discourse.gohugo.io/t/hide-content-from-single-template/4239/7 "2017-09-15T21:07:39Z")

</div>

@bep, please, can we rely on this technique?

---

<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:** [September 15, 2017, 9:10pm UTC](https://discourse.gohugo.io/t/hide-content-from-single-template/4239/8 "2017-09-15T21:10:40Z")

</div>

> [@robsonsobral](#):
>
> @bep, please, can we rely on this techniq

Yes, this is future safe – but it creates a warning in the log. There is a similar open issue about somethings similar … @budparr may know more …

---

<div class="post-metadata">

**Author:** ![robsonsobral](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/robsonsobral/32/1628_2.png) [@robsonsobral](https://discourse.gohugo.io/u/robsonsobral)\
**Post date:** [September 15, 2017, 9:16pm UTC](https://discourse.gohugo.io/t/hide-content-from-single-template/4239/9 "2017-09-15T21:16:28Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![budparr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/budparr/32/749_2.png) [@budparr](https://discourse.gohugo.io/u/budparr)\
**Post date:** [September 15, 2017, 9:18pm UTC](https://discourse.gohugo.io/t/hide-content-from-single-template/4239/10 "2017-09-15T21:18:48Z")

</div>

Aside from data files, `layout: none` is fine unless you have a lot of pages (or would have to rely on clients to set it).

I do have an open issue on this: [https://github.com/gohugoio/hugo/issues/3612](https://github.com/gohugoio/hugo/issues/3612) though my biggest reason for it is to improve performance on larger sites where outputting every single page isn’t necessary.

For a hacky workaround, that I would not guess is future-proof, you can create the single template and put nothing in it. It’s been working for me, though it breaks when running benchmark.

---

<div class="post-metadata">

**Author:** ![robsonsobral](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/robsonsobral/32/1628_2.png) [@robsonsobral](https://discourse.gohugo.io/u/robsonsobral)\
**Post date:** [September 18, 2017, 1:48am UTC](https://discourse.gohugo.io/t/hide-content-from-single-template/4239/11 "2017-09-18T01:48:57Z")

</div>

I don’t think our needs exactly match. You want to avoid render all pages again and again. I need to create markdown files for parts of pages, being FAQs one of the cases.

But your need is a valid one, for sure!

---

<div class="post-metadata">

**Author:** ![robsonsobral](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/robsonsobral/32/1628_2.png) [@robsonsobral](https://discourse.gohugo.io/u/robsonsobral)\
**Post date:** [September 18, 2017, 1:50am UTC](https://discourse.gohugo.io/t/hide-content-from-single-template/4239/12 "2017-09-18T01:50:20Z")

</div>

Do you think `layout: none` can be part of docs, @digitalcraftsman? I know a lot of developers want to use several MD files for homepages, faqs, sessions of events, etc, etc…

---

<div class="post-metadata">

**Author:** ![digitalcraftsman](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/digitalcraftsman/32/4142_2.png) [@digitalcraftsman](https://discourse.gohugo.io/u/digitalcraftsman)\
**Post date:** [September 19, 2017, 12:46pm UTC](https://discourse.gohugo.io/t/hide-content-from-single-template/4239/13 "2017-09-19T12:46:56Z")

</div>

Feel free to add a note to the documentation. Contributions are always welcomed.

---

<div class="post-metadata">

**Author:** ![robsonsobral](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/robsonsobral/32/1628_2.png) [@robsonsobral](https://discourse.gohugo.io/u/robsonsobral)\
**Post date:** [September 19, 2017, 5:00pm UTC](https://discourse.gohugo.io/t/hide-content-from-single-template/4239/14 "2017-09-19T17:00:54Z")

</div>

Done, boss!

---

<div class="post-metadata">

**Author:** ![gaetawoo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/gaetawoo/32/16789_2.png) [@gaetawoo](https://discourse.gohugo.io/u/gaetawoo)\
**Post date:** [September 19, 2017, 9:40pm UTC](https://discourse.gohugo.io/t/hide-content-from-single-template/4239/15 "2017-09-19T21:40:10Z")

</div>

I’m curious, what is your specific use case for this? I read the thread above but I don’t see what the idea is behind this and I’d like to learn!

---

<div class="post-metadata">

**Author:** ![robsonsobral](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/robsonsobral/32/1628_2.png) [@robsonsobral](https://discourse.gohugo.io/u/robsonsobral)\
**Post date:** [September 19, 2017, 9:51pm UTC](https://discourse.gohugo.io/t/hide-content-from-single-template/4239/16 "2017-09-19T21:51:55Z")

</div>

Of course!

- FAQs, with one MD for every question;
- features section on homepage;
- single page sites;

The three cases have occurred to me in the last few months. FAQ is the most common. I can submit the files to different people on team to write the answers. The idea is to split a single MD content into several parts without to write HTML.

---

<div class="post-metadata">

**Author:** ![gaetawoo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/gaetawoo/32/16789_2.png) [@gaetawoo](https://discourse.gohugo.io/u/gaetawoo)\
**Post date:** [September 19, 2017, 9:55pm UTC](https://discourse.gohugo.io/t/hide-content-from-single-template/4239/17 "2017-09-19T21:55:17Z")

</div>

how do you put them together and display/render them?

---

<div class="post-metadata">

**Author:** ![robsonsobral](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/robsonsobral/32/1628_2.png) [@robsonsobral](https://discourse.gohugo.io/u/robsonsobral)\
**Post date:** [September 19, 2017, 11:44pm UTC](https://discourse.gohugo.io/t/hide-content-from-single-template/4239/18 "2017-09-19T23:44:05Z")

</div>

Having a `content/faq.md` and a bunch of questions within `content/faq/`:

```auto
{{ .Content }}
{{ range where $.Site.RegularPages ".Type" "faq" }}
	<details id="faq__{{ .File.TranslationBaseName }}">
		<summary>{{ .Title | safeHTML | markdownify }}</summary>
		{{ .Content }}
	</details>
{{ end }}

```

To make them easy to get, I set their `type` on frontmatter.
