Frontmatter images?

Each of my posts frontmatter contain the following like so:

---
title: "My Story"
image: "logo.png"
---

Each of my posts has a folder named ‘images’ alongside it. For example, I have a folder called ‘Blogs’ which contains ‘blog_1.md’ and a folder named ‘images’ which contains ‘logo.png’.

On my homepage (index.html), I have all my posts listed by their urls to access them. Next to these urls I would like each posts ‘logo.png’ to be next to them. Does anyone know how I can go about this?

Any help would be much appreciated. Thanks.

Repo: GitHub - jpnfighter/new-steve

I would organize content into leaf bundles:

content/
├── blogs/
│   ├── blog-1/
│   │   ├── index.md
│   │   └── logo.png
│   └── blog-2/
│       ├── index.md
│       └── logo.png
└── _index.md

This way the image is associated with the content, and you don’t need to specify the image in front matter. Your template can then do something like:

{{ range site.RegularPages }}
  <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
  {{ with .Resources.GetMatch "logo.*" }}
    {{ with .Resize "200x" }}
      <img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
    {{ end }}
  {{ end }}
{{ end }}
2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.