Link to IRC in menu doesn't work

#1

Hello,

I am using Hugo and in my config.toml I define my menu bar items :


[[menu.main]]
name = “PHOTOS”
pre = “
weight = -120
url = “https://abordes.ynh.fr/gallerie/

[[menu.main]]
name = “RSS”
pre = “
weight = -70
identifier = “rss”
url = “https://abordes.ynh.fr/blog/index.xml

[[menu.main]]
name = “IRC: Arnob at geeknode”
url = “irc://irc.geeknode.org”

It works fine except for the IRC menu. When I generate my blog, the result link when clicking in the menu for the irc is :

https://abordes.ynh.fr/blog/#ZgotmplZ

instead of : irc://irc.geeknode.org

So after generating my blog, if I look at the html files in the public folder, the menu item for IRC is this :

<ul class="sidebar-nav">
      <li><a href="https://abordes.ynh.fr/blog">ACCUEIL</a> </li>
      <li><a href="/blog/about/"> A PROPOS </a></li><li><a href="https://abordes.ynh.fr/gallerie/"> PHOTOS </a></li><li><a href="/blog/tags/"> TAGS </a></li><li><a href="https://abordes.ynh.fr/blog/index.xml"> RSS </a></li><li><a href="#ZgotmplZ"> IRC: Arnob at geeknode </a></li>
    </ul>

As you can see, I have href="#ZgotmplZ instead of the expected irc://irc.geeknode.org …

To understand better my problem you may visit my blog https://abordes.ynh.fr/blog/ and click on the IRC item in the menu bar (last item on the left).

Thank you for any help.

Help with unsafe content at runtime
#2

“ZgotmplZ” is a special value that indicates that unsafe content reached a CSS or URL context at runtime.

You are looking for https://gohugo.io/functions/safehtmlattr/. It has your exact issue as the example.

#3

Ok, thank you.

So what I understand is that I have to add :

<a href="{{ .URL }}"> → <a href="#ZgotmplZ">
<a {{ printf "href=%q" .URL | safeHTMLAttr }}> → <a href="irc://irc.geeknode.org">

somewhere?

But where?

#4

You put that where your menu is generated, in your templates. If you need more help, please follow the suggestions at Requesting Help and share your code, so folks may assist you.

1 Like
#5

Ok, thank you.