Problem with Hero Image

You’ve already had that conversation…

This doesn’t make any sense. .Params.heroimage is not an array.

{{ with .Params.heroimage }}
    {{ index . 0 | relLangURL }}
{{ end }}

You want:

{{ with .Params.heroimage }}
    {{ . | relLangURL }}
{{ end }}
1 Like

I finally solved a problem on my own (for the contact page)
And it’s a little thanks to you

THANKS !!!

PS just to be sure
for add an url in a html template i used
<a href="{{ .Site.Params.genres_path | relLangURL }}">Liste des genres</a>

And i add in config.toml

[params]
    genres_path = "genres/"

And another case
for my shortcode
hugo-blank-theme-v3\themes\sandbox\layouts\shortcodes\hero-index.html

i put this line of code
background-image: url({{ .Site.BaseURL | relLangURL }}/images/blog/enfantDuRetro.jpg);

It’s the good way to do that ?
Or will I have problems deploying to githubpages?

Never use .Site.BaseURL in your templates. That value was exposed to the templates a long time ago, before we had other ways to resolve relative URLs to the site root.

Even if we recommended using .Site.BaseURL, your construct above does not make sense. Do this instead:

url({{ "images/blog/enfantDuRetro.jpg" | relLangURL }});

Or if you need an absolute URL:

url({{ "images/blog/enfantDuRetro.jpg" | absLangURL }});
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.