Frontmatter image?

I’m having trouble having an image be defined in my frontmatter. I have the title working nicely, but can’t figure out how to do images.



post.md:

---
title: "post"

image: "1uEpd4IzXgwCzfxwivCTzbM5_ViMPLjZY"
---

Hello world.




layouts>shortcodes>image.html:

<img src="https://drive.google.com/uc?id={{ .Get 0}}">




single.html:

<br>Title: {{ .Title }}
<br>Image: <!--?-->




repo: GitHub - jpnfighter/steve-site: hugo website

If you’re going to show the image in the partial, just modify the single.html as follows.

<br>Title: {{ .Title }}
<br>Image: {{ with .Params.image }}<img src="https://drive.google.com/uc?id={{ . }}">{{ end }}

And you can’t include the shortcode in the template, but you can save it as a partial.

single.html

<br>Title: {{ .Title }}
<br>Image: {{ partial "image" . }}

layouts/partials/image.html

{{ with .Params.image }}
<img src="https://drive.google.com/uc?id={{ . }}">
{{ end }}

You can find more vars on Page Variables and access custom variable via .Params in template (not shortcode).

2 Likes

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