Loop through YAML data file when related to posts

Hi Hugo users,

I’ve been playing with Hugo recently and I had an idea for static comments but can’t manage to solve my issue.

I want comments to be stored in data/post with each comment file named after the same blog post. However it does not seem to work and I don’t know why, here is the partial that I have in single.html :

`{{ range $.Site.Data.post }}
{{ range .File.LogicalName }}

{{ .content | markdownify }}
{{ end }} {{ end }}`

Written like that I understand that Hugo can find the data/post/basenameofmypost.yaml that I need to render the content: "blablabla".

Do you know what’s wrong ?


Look at the index func.

Thanks I will have a look at it.

Sounds that I want to build something too hard for my brain :slightly_smiling:

Thanks to @bep I managed to get my .YAML in data/post linked to my content/post files.

I think about using data files to store comments for my blog:

For example one YAML file could contain :
id: 1 name: John Doe date: 2017-02-06 content: First id: 2 name: John Two date: 2017-02-06 content: Second

The thing I want to do is to show each content data for each id

For now I have
{{ with (index .Site.Data.post (substr $.File.LogicalName 0 -3)) }}

{{ .content | markdownify }}

{{ end }} `

But it only shows the last content parameter.

Any clue ?