Hi all,
I’m trying to embed an image/page resource into a blog post. I placed both the image and index.md
in content/posts/my-first-post/
. My index.md
looks as follows:
---
title: "My First Post"
---
# Page Resources
![](hugo-logo.png)
{{% figure src="hugo-logo.png" %}}
# Static Resources
![](/static-logo.png)
{{% figure src="/static-logo.png" %}}
<!--more-->
More text.
When running hugo server -D
, http://localhost:1313/posts/my-first-post/
looks as expected:
[link to image, new users can only add one image to a post…]
However, the index page (http://localhost:1313/
) doesn’t render the page resources as the paths aren’t adjusted:
I came up with the following shortcode as a workaround:
{{ $img := .Page.Resources.GetMatch (.Get "src") }}
<figure>
<img src="{{ $img.RelPermalink }}"/>
</figure>
That does work, but it looks wrong to me that I have to either write my own shortcode or put everything into ./static for this rather basic task. Am I missing anything?
To make this easy to reproduce, there’s a minimal example project at https://github.com/mhils/hugo/tree/img-src.
Thanks!