[SOLVED] Content is not a field of struct type in homepage layout

I have the following structure in my project.


In my homepage layout I want to access the content of the _index.md file. Including {{.Content}} in the template is resulting in the following error:

Error while rendering homepage: template: theme/index.html:37:12: executing “theme/index.html” at <.Content>: Content is not a field of struct type

When I loop over the content in the index.html file I see the _index.md as a separate post. Doesn’t seems right?

{{- range first 10 .Data.Pages }}
      <h4><a href="{{ .Permalink }}">{{ .Title }}</a></h4>
      {{- end }}

To skip over the index pages in your range, try .Site.RegularPages

My problem is that {{.Content}} is not available in the index.html. Therefore it is not possible to display the content of _index.md in the index.html template.

Excuses if my question was not clear.

Right, I was addressing the following:

What version of Hugo are you using? Also, can you point me to source code somewhere?

mmm was running a old version of hugo installed via apt-get. Just installed to the most recent version van hugo and everything is working fine!

Thanks for helping me out.

1 Like