# \_index.md ignores type for layout rendering

**URL:** <https://discourse.gohugo.io/t/-index-md-ignores-type-for-layout-rendering/5679>\
**Category:** support\
**Created:** [March 3, 2017, 11:02pm UTC](https://discourse.gohugo.io/t/-index-md-ignores-type-for-layout-rendering/5679 "2017-03-03T23:02:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rwi](https://avatars.discourse-cdn.com/v4/letter/r/cc9497/32.png) [@rwi](https://discourse.gohugo.io/u/rwi)\
**Post date:** [March 3, 2017, 11:02pm UTC](https://discourse.gohugo.io/t/-index-md-ignores-type-for-layout-rendering/5679/1 "2017-03-03T23:02:05Z")

</div>

I have a question related the `type` property in the front-matter for `_index.md` files.

Althought I’ve read the realeted posts [https://discuss.gohugo.io/t/-index-md-pages-in-section-taxonomies-etc-are-not-rendered-using-single-html-template/5466](https://discuss.gohugo.io/t/-index-md-pages-in-section-taxonomies-etc-are-not-rendered-using-single-html-template/5466) and [https://discuss.gohugo.io/t/static-page-in-content-not-rendering-correctly/5427/16](https://discuss.gohugo.io/t/static-page-in-content-not-rendering-correctly/5427/16) I’m not really more clever.

Assuming a project where you have the following `content`-Structure:

```nohighlight
content
  |-- zurich
  | |-- _index.md
  | |-- venue-a.md
  | |-- venue-b.md
  |-- amsterdam
  | |-- _index.md
  | |-- venue-a.md
  | |-- venue-b.md
  |-- new-york
  | |-- _index.md
  | |-- venue-a.md
  | |-- venue-b.md

```

All `venues` and `citites` (sections) have the same structure so according to DRY I was thinking about having the following layout structure:

```nohighlight
layouts
  |-- city
  | |-- list.html
  |-- venue
  | |-- single.html

```

and assigning the appropriate front-matters to a `_index.md` and the `venue-x.md` files like:

`_index.md`

```auto
title = "Zurich"
type = "city"

```

`venue-xyz.md`

```auto
title = "Venue XYZ"
type = "venue"

```

(obviously I’ve made a reduced front-matter example without date, description etc. above just to get the idea.)

* * *

Well, the `venue`-Layout (Single) renders as expected however the `city`-Layout does not really work out and fall back to the `_default/list.html`-layout or using the section layout like `layouts/section/zurich.html` or `layouts/section/amsterdam.html`…

I am wondering if I miss something or this functionality is planned in the future or what are the reasons to ignore the `type` for `_index.md`-files?

Any help or hints in the right direction are welcome.

---

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [March 3, 2017, 11:22pm UTC](https://discourse.gohugo.io/t/-index-md-ignores-type-for-layout-rendering/5679/2 "2017-03-03T23:22:48Z")

</div>

I’m not 100% I caught all of that, but I think your mistake is that you are treating `_index.md` as a single page, when it’s actually a list page…hence why it’s falling back to `_default/list.html`. That said, you can work around this within your existing templates by leveraging features like `kind` or just using content views…

---

<div class="post-metadata">

**Author:** ![rwi](https://avatars.discourse-cdn.com/v4/letter/r/cc9497/32.png) [@rwi](https://discourse.gohugo.io/u/rwi)\
**Post date:** [March 3, 2017, 11:32pm UTC](https://discourse.gohugo.io/t/-index-md-ignores-type-for-layout-rendering/5679/3 "2017-03-03T23:32:25Z")

</div>

Okay, so I should use the `kind`-Property for stuff like this. Unfortunately I’m a bit lost with the new `kind` property.

As far as I understood the changes in v0.18 correct with a sentence like `Everything is a Page now.` and you have access to the Front-Matters of `_index.md` on the list pages.

I’m unclear how to control the layouts with the new `kind` property. Could you give me a short hint how I should change the content and layout organisation to achieve a matching result?

Given the above stated content-structure I try to achieve the following:

`/zurich/` \<- an index page listing all venues within this folder  
`/zurich/venue-a` \<- A detail page for venue-a (works well)  
…  
`/amsterdam/` \<- an index page listing all venues within this folder  
`/amsterdam/venue-b` \<- A detail page for venue-b (works well)  
…

---

<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 3, 2017, 11:33pm UTC](https://discourse.gohugo.io/t/-index-md-ignores-type-for-layout-rendering/5679/4 "2017-03-03T23:33:59Z")

</div>

> <https://github.com/gohugoio/hugo/issues/3005>

---

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [March 3, 2017, 11:51pm UTC](https://discourse.gohugo.io/t/-index-md-ignores-type-for-layout-rendering/5679/5 "2017-03-03T23:51:44Z")

</div>

> [@rwi](#):
>
> /zurich/ \<- an index page listing all venues within this folder/zurich/venue-a \<- A detail page for venue-a (works well)…/amsterdam/ \<- an index page listing all venues within this folder/amsterdam/venue-b \<- A detail page for venue-b (works well)

Hmm. If this is all you want, I think this is just standard for Hugo and you don’t need to do kind or content views. I thought you were asking for something much more complex. Why not just put one template at `layouts/section/zurich.html` that lists all the `zurich` pages and then another at `layouts/section/amsterdam.html`…but I can see how that wouldn’t be the most flexible and easy to use if you have, for example, folders for 100 cities 😄

But it looks like @bep is on it with this type/layout issue to get what (I assume from your original post) you want done in terms of source organization. Also, he [recently committed this enhancement](https://github.com/spf13/hugo/issues/3116) for v20, which will at least make the lookup order for sections more consistent (and therefore less confusing). [Here are the docs on content views as well](http://gohugo.io/templates/views/), although this won’t respect “type” necessarily, you could have another front matter variable to check for in your `list.html` and then use `.Render` to show the appropriate view…

---

<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 3, 2017, 11:57pm UTC](https://discourse.gohugo.io/t/-index-md-ignores-type-for-layout-rendering/5679/6 "2017-03-03T23:57:53Z")

</div>

I have not read all of this, but also note the small but important recent change I did with the section layout selection. With the latest dev version you can put

/mysection/single.html  
/mysection/list.html

Etc.

---

<div class="post-metadata">

**Author:** ![rwi](https://avatars.discourse-cdn.com/v4/letter/r/cc9497/32.png) [@rwi](https://discourse.gohugo.io/u/rwi)\
**Post date:** [March 3, 2017, 11:59pm UTC](https://discourse.gohugo.io/t/-index-md-ignores-type-for-layout-rendering/5679/7 "2017-03-03T23:59:22Z")

</div>

@rdwatters - Yes, this is what I did to overcome the current situation, but I definitely want to avoid creating the same template file named like the section folder. This will end up in a huge mess of repeating code. (Yes, there will be hundreds of cities in the project)

* * *

When I read the documentation for `Single`-Layouts properly where the `type` is included in the orders.

Single:

```auto
/layouts/TYPE/LAYOUT.html
/layouts/SECTION/LAYOUT.html
/layouts/TYPE/single.html
/layouts/SECTION/single.html
/layouts/_default/single.html
/themes/THEME/layouts/TYPE/LAYOUT.html
/themes/THEME/layouts/SECTION/LAYOUT.html
/themes/THEME/layouts/TYPE/single.html
/themes/THEME/layouts/SECTION/single.html
/themes/THEME/layouts/_default/single.html

```

why not to follow the same structure for the `list`-Pages like:

```plaintext
> /layouts/TYPE/list.html
> /layouts/SECTION/list.html
/layouts/section/SECTION.html
/layouts/_default/section.html
/layouts/_default/list.html
> /themes/THEME/TYPE/list.html
> /themes/THEME/SECTION/list.html
/themes/THEME/layouts/section/SECTION.html
/themes/THEME/layouts/_default/section.html
/themes/THEME/layouts/_default/list.html

```

Okay, a valid point is where to put the LAYOUT for lists is unclear to me, since I’ve never used it.

* * *

> [@bep](#):
>
> /mysection/single.html  
> /mysection/list.html

Cool, thanks for this. As far as I see it - this helps to organize section-templates better, but as a developer you still need to create a section in your layouts for each section you have. Even they are equal in the structure.

---

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [March 4, 2017, 12:05am UTC](https://discourse.gohugo.io/t/-index-md-ignores-type-for-layout-rendering/5679/8 "2017-03-04T00:05:50Z")

</div>

> [@bep](#):
>
> but also note the small but important recent change I did with the section layout selection.

Haha, I mentioned that 😉

> [@rwi](#):
>
> why not to follow the same structure for the list-Pages like:

I think that’s what bep is trying to do with the issue he just opened for the project, [as mentioned above](https://github.com/spf13/hugo/issues/3005).

Right now, you can create individual list files at `layouts/section/sectionname.html` that fall back on `layouts/_default/section.html` and then to `/layouts/_default/list.html`.

There are lots of ways to keep this DRY, even with the current limitation of section pages not respecting type and layout…you can use partials, etc…I guess the question is how many unique/different layouts are you planning on having in this site?
