Generate wrong img-output.html from figure shortcodes (baseURL)

Hi, iam having some isues with Hugo’s built-in figure shortcodes.

i haved added several figure shortcodes to files .md using i.e.:

{{< figure src=“img/pandas_14.jpg” >}}

but when i run hugo, it’s not capable to add the baseURL path to the img-output.html

I’ve put all the path (baseURL included) in the figure shortcodes to create the site with hugo and it’s worked…(but iam not been able to see the image when iam creating new .md files)

i have:
in config.toml
baseURL = “Petrofísica en Python

hugo v0.100.1+extended windows/amd64
theme: Blonde

besides this issue…Hugo is awesome :slight_smile:

Thank you!!

could you share your figure shortcode code? it probably missing absURL or something like that.

Hi idarek, all shortcodes i put in the .md files look like them:
{{< figure src=“img/pandas_14.jpg” >}}
{{< figure src=“img/csv_pandas_sns_06.jpg” >}}

A, get that. This is a build-in shortcode and its behaviour is as expected, without adding a full path.

The code is:

<figure{{ with .Get "class" }} class="{{ . }}"{{ end }}>
    {{- if .Get "link" -}}
        <a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
    {{- end -}}
    <img src="{{ .Get "src" }}"
         {{- if or (.Get "alt") (.Get "caption") }}
         alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
         {{- end -}}
         {{- with .Get "width" }} width="{{ . }}"{{ end -}}
         {{- with .Get "height" }} height="{{ . }}"{{ end -}}
    /><!-- Closing img tag -->
    {{- if .Get "link" }}</a>{{ end -}}
    {{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}}
            {{ with (.Get "title") -}}
                <h4>{{ . }}</h4>
            {{- end -}}
            {{- if or (.Get "caption") (.Get "attr") -}}<p>
                {{- .Get "caption" | markdownify -}}
                {{- with .Get "attrlink" }}
                    <a href="{{ . }}">
                {{- end -}}
                {{- .Get "attr" | markdownify -}}
                {{- if .Get "attrlink" }}</a>{{ end }}</p>
            {{- end }}
    {{- end }}

Will have a look if I or somebody else managed to provide output with an absolute URL, but do you really need that? Heres why.

This shortcode will work in post folder structure. Each image will be in img folder that is down in post folder.

For example, if you got /posts/my-first-post/ than img/pandas_14.jpg will refers to http://localhost:1313/posts/my-first-post/img/pandas_14.jpg.

Cannot just add absURL (<img src="{{ .Get "src" | absURL }}") as than this will refers to files stored directly in your content and there img folder http://localhost:1313/img/pandas_14.jpg.