How to show subsection in Template?

The template vars{{ .Section }} or {{ .Type }} from \post\news\ shows only “post” not “news”. I wan´t show post (from root), news (subfolder), event (subfolder) etc.

How can i solve this?

Infos: My Single Template ist under \themes\THEME\layouts\post\single.html

Info: hugo.exe v0.14 Windows

1 Like

From “Hugo assumes that your site will be organized into sections and each section will use the corresponding type. … each new piece of content you place into a section will automatically inherit the type.”

If you want to have types separate from the section, you must set “type” in the front matter. If you want to do this a lot, I’d recommend creating a “news” archetype.

1 Like


I am having the same issue. I am not able to filter by the sub-folder (sub-section or sub-type).

I have the following folders and files.


I created a “comment” archetype in testsite\themes\ft\archetypes. but it didn’t work so I have to move “” to testsite\archetypes then it works. I have the code below in


In single.html, I have this code.


<p>{{.Content}} </p>

{{ $commentPages := where $.Site.Pages "Section" "comment" }}

{{ range  $commentPages }}
	  <a href="{{ .Permalink }}">
		{{ .Title }} - {{ .Section }} - {{ .Type }} 
 {{ .Content }} <br/>
{{ end }}

When I go to http://localhost:1313/post/first/, it will show all comments. I like to filter the comments under /comment/first/ folder.

I think I should add a where condition at {{ range $commentPages }} but I am not sure which identifier that I can use to filer it. Could you please give me some pointers on this filtering part?


Hugo has no concept of sub-sections. Top-level sections only.



I think I managed to get what I want to achieve now. I will share it for feedback after I’ve done a few tests.

Thanks all!