How to have a nice URL for static image

I have a shortcode that inserts structured data on my page for SEO.
I’m wondering how I can reference a static image file and return the URL.
Currently, I’m doing this:
“logo”: {{ print .Site.BaseURL “icons/favicon.svg” }},
“image”: [
{{ print .Site.BaseURL “icons/favicon.svg” }},
{{ print .Site.BaseURL “icons/logo_text_blue.svg” }}

However I would like to do something like {{ ref . “/icons/favicon.svg” }}, but that doesn’t work. I think it only works for pages.

Any suggestions to make this better?

What does that mean? Be specific.

Do not use .Site.BaseURL or site.BaseURL in your templates.

By that doesn’t work, I mean that I get an error saying page not found.
But, I have the image in /static/icons/favicon.svg.
Does ref only work with content pages?

ERROR [en] REF_NOT_FOUND: Ref “/icons/favicon.svg”: “/Users/ntenpas/Desktop/presence-site/hugo/content/”: page not found
ERROR Rebuild failed: logged 1 error(s)

Use relURL or relLangURL. See docs.

1 Like

Thank you!

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