Images with custom permalink


Hey folks,

I have started migrating my personal blog over from Pelican to Hugo and I’m not sure how to tackle resources.

tl;dr - Is there a shortcode or way of referencing the .Dir page property to properly include images when using custom permalinks?

I don’t mind restructuring my source content, but I really would love to keep images together with post markdown.

What I was doing
I want to keep each blog post in it’s own directory and house it’s assets alongside markdown, similar to how page (I think) bundles work.

This is the structure I’m using currently:

- content/
  - posts/
    - YYYY/ 
      - MMDD_SHORT/
        - *.md
        - (resources)

Additionally, I have customised the permalink in the

  posts = "/:year/:slug/"

What I expected
Either of the following:

  1. Resources referenced in the front matter to be rendered to the same canonical folder as the permalink
  2. A short-code I could use to reference the .Dir property for the

What actually happened
Image references are broken because resources are in a different location and I don’t know how to reference them.

Here’s a minimal reproduction of my problem.


Is Page Resources out of the question ?


I was expecting the markdown syntax for images to work, ie::

![the blue duck](duck.jpg)

It’s not clear to me as a newcomer how Page Properties are supposed to work in Markdown, if at all? Does the following look right? (It definitely doesn’t appear to work).

![the blue duck]({{ (.Resources.GetMatch "duck.jpg").RelPermalink }})


Actually, I think what I need is a custom shortcode - this link is starting to make more sense to me:

I’ll give this a go and let you know if that works. Do you think it’s worth submitting a pull request to improve support for the Markdown renderer? I would kind of expected it to work that way out of the box.

Edit: Nope, I’m pretty certain I’m doing something dumb - I’ll keep trying. Thanks and definitely open to suggestions on how to do this different or better.


try this


Woohoo, got it sorted! Resources weren’t being copied to the permalink folder or appearing in the .Page.Resources data.

It turns out that Page Bundles don’t work unless your bundles page is named

Thanks for the assistance folks!