relURL not always outputing URL


#1

<div style="background-image: url('{{ "/img/principal.jpg" | relURL }}');">

outputs:

<div style="background-image: url('/img/principal.jpg');">

But

<img src="{{ "/img/icon-form.png" | relURL }}">

Outputs:

<img src="../../img/icon-form.png">

The image is correct, the inline style is not.

config.yaml:

relativeURLs: true
canonifyURLs: false
uglyurls: false

Why is this happening?

Thank you!


#2

More information is needed to troubleshoot your issue. Please read Requesting Help and update your post. :slight_smile:


#3

I’m running this on version 0.46

The weird thing is I’m getting this difference in behavior on the same partial.

This is a custom theme, but unfortunately I can’t really share it (intranet site).

Can you at least confirm that this is not the normal behavior? Meaning that the relURL output should have the same root.

Thanks


#4

Is your Hugo site published in a sub-directory of the intranet?