Consistent access URL to resources in page bundle

It seems that there are 3 ways to access resources in the page bundle depending on the disablePathToLower and uglyURLs settings.

$ tree content/sampleBundle/
content/sampleBundle/
├── index.md
└── sample.jpg

0 directories, 2 files
$ cat content/sampleBundle/index.md 
---
title: sample bundle
---

access url to `sample.jpg` in page bundles

| disablePathToLower | uglyURLs | url                     |
|--------------------|----------|-------------------------|
| any                | false    | sample.jpg              |
| true               | true     | sampleBundle/sample.jpg |
| false              | true     | samplebundle/sample.jpg |

- [sample.jpg](sample.jpg)
- [sampleBundle/sample.jpg](sampleBundle/sample.jpg)
- [samplebundle/sample.jpg](samplebundle/sample.jpg)

I want to make shortcode for release this situation however
I cannot find the way to accessing disablePathToLower and uglyURLs value in short code,

Are there any workaroud?

Use a markdown render hook with .Resources.Get. Its .RelPermalink and .Permalink values figure that out for you.

I can use .Page.Resources in shortcode to access resource metadata.
Thank you for your advice.

B.T.W,
Are there any way to render markdown snippet in short code (e.g ‘[XX](URL)’) ?

I use theme which extends link behavior by THEME/layouts/_default/_markup/render-link.html
To adhere the policy of the theme, should I copy render-link.html into my short code?

You don’t need a shortcode to resolve the situation.

You can create layouts/_default/_markup/render-image.html to hook into the markdown image rendering.

Let me know if you need a sample.

1 Like

Just find that the theme I use (https://geekdocs.de/) provides good example to handle the resource for a image.I should have checked more carefully.

I pickked sample.jpg just as a sample. HTML and other types also exists.
To simplify, I chose to define the small short code which just resolve resource URL and use it in link [XX]({{< my-shortcode "sample.html" >}})

The default render hook for that theme really doesn’t do anything.

https://github.com/thegeeklab/hugo-geekdoc/blob/main/layouts/_default/_markup/render-image.html

Sorry,
I mistook it for another file.

The markdownify function helps me.

I choose markdownify to adhere the policy of the theme.
The theme define render hook for link to add some classes.

memo on render hook

Oh , I see.

$.Page.RenderString seems also work with ‘render hook’