[SOLVED] How to add relURL to: {{< figure src=


#1

Hi
I have an issue with the built in figure shortcode.

baseurl = "http://example.com"

static/
└── img
    ├── gohugo.io
    │   └── hugo.ipsum.png

{{< figure src="/img/gohugo.io/hugo.ipsum.png" >}}

All fine. But with
baseurl = "http://example.com/foo"

I still get:
figure
img src="/img/gohugo.io/hugo.ipsum.png"

missing the foo part.

How do I use relURL with the figure shortcode?
Or is there any other solution (without recreating the built in shortcode)?

(Hugo Static Site Generator **v0.32.3** linux/amd64 BuildDate: 2018-01-09T15:21:59+01:00)

Testing site is here:


#2

Seems code is here:
https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/template_embedded.go

<img src="{{ .Get "src" }}"

Doc is here:
https://gohugo.io/content-management/shortcodes/#use-hugo-s-built-in-shortcodes

{{< figure src="/media/spf13.jpg"

If baseurl is someting like “http://example.com/foo” - I think this will fail.

I’ve taken into advice:
https://gohugo.io/themes/creating/

If you’re creating a theme with plans to share it with the community,
use relative URLs since users of your theme may not publish from the root of their website

Does this apply to internal shortcodes as well (?).

I currently see no way how to use {{< figure … in a project if it is not guaranteed that the project will be (and stay) in the root.

Looks like recreating the figure shortcode in the template for the project the only way…


#3

That is the only way. If you need something more than what an internal shortcode already offers, you recreate it