Troubleshooting list template - Ranges show, Content is missing

Hi everyone. I apologise if this is an uninformed question. I’ve done my best to read the docs, watch the tutorials and search the forums. I can’t figure it out.

{{ .Content }} isn’t appearing inside my list template. It appears fine in my single template.

My list.html sits inside layouts/_default/ This is its content.

{{ define "main" }}

{{ .Content }}

{{ partial "range.html" . }}

{{ end }}

range.html is just the usual:

<ul class="range">
  {{ range .Pages }}
      <a href="{{ .URL }}">{{ .Title }}</a>
  {{ end }}

The list templates render the ranges perfectly, with all the requested page content but without the {{ .Content }} content.

I have content appropriately placed in my content directory to show up at the top of these list pages. I’m not sure how to make it show up. Is anyone able to offer a suggestion?

Why are you rendering your content on the list page? List pages aren’t meant for that. While I may not be very experienced in Hugo, according to my understanding, list pages only serve as sort of reference pages for single pages. Therefore that may be why you’re unable to render {{ .Content }} there.
Could you also explain what you’re aiming to do?


Say, I have a list of posts. At the top of that list, I’d like to insert some {{ .Content }} that I can populate via markdown from inside the Content directory.

The purpose of that content might be to pre-announce what is in the list.

Oh that is what you meant to do. Hugo already provides a function to do so, {{ .Summary }}. Read the docs here: Content Summaries. There’s also a helpful example to do exactly what you want.


What does your content directory look like?

Thank you, though I’m afraid {{ .Summary }} is generated per post. I’m attempting to insert arbitrary {{ .Content }} above those posts (not to mention, insert front-matter).

Thanks! My content structure is like this:
  ⌙ blog/
      ⌙ post1/
      ⌙ post2/

edited: Renamed a file.

Assuming that’s not a typo, you need to rename that to See here for the difference between and

Thanks. Good spot.

I have been experimenting with the naming of that file while attempting to troubleshoot this. I’ve put it back to, and I’m still seeing the above behaviour.

Being a list/branch, it rightly shows the child pages. I just can’t get it to respect the front matter or {{ .Content }} defined in

edit: If I delete it renders the same thing. I think the issue is that the markdown _index file is being ignored.

How odd. You may need to share your site code for us to be able to help you better. If you are unable to share the full site, a smaller one with just enough layouts and dummy content that reproduces the error would help.

1 Like

Thanks for suggesting this.

I just set up a new project, and couldn’t reproduce the issue - obviously. :stuck_out_tongue:

I ended up comparing the config files, and mine has had some extra parts added. It looks like if I add:

tag         = ""
category    = ""

to my config, then it creates the above issue. I’m still relatively new to Hugo, and I forgot why I added these. So I’ve deleted them. All is well. :sweat_smile:

This has been happening to me too, I had this in my config to disable the taxonomy pages from being generated and included in the sitemap.

[edit] looks like there’s a newer way to do that now

1 Like