Text gets rendered outside href in shortcode

#1

Small but quite annoying little bug with the way href gets rendered in a shortcode.

You see that “stats for nerds” at the right bottom corner of the website?

{{ $book_name := .Get 0 }}
<div class="small p-0 m-0">
   <a href="{{ .Site.BaseURL }}journal/{{ .Get 2 }}">{{ $book_name }}</a>
</div>

In hugo server, the link gets rendered ok:

<div class="small p-0 m-0">
   <a href="http://localhost:1313/journal/mythos-a-silicon-valley-thriller/">MYTHOS A Silicon Valley Thriller (release)</a>
</div>

But when I do hugo --minify, this is what I get:

<div class="small p-0 m-0">
   <a href="http://localhost:1313/journal/mythos-a-silicon-valley-thriller/"></a>
   MYTHOS A Silicon Valley Thriller (release)
</div>

See that little bastard there? It renderedoutside the freaking link!

I’m using jQuery to grab that from a post, by the way.

jQuery

$( "#nerdstats" ).load( "../../books/index.html #nerdstats__data" );

And this here is the shortcode:

Shortcode:

{{< nerdstats "MYTHOS A Silicon Valley Thriller (release)" "100" "mythos-a-silicon-valley-thriller/" >}}

It renders as it should during server mode, but when I mix hugo with jQuery, during export? Things go wild!

Anyone knows how to solve this one?

EDIT
I hacked my way using onclick to simulate the links and css styles to simulate the text-decoration when mouse over (besides cursor:pointer), so it now “works”, but hacked.

Regularly, the error will still be happening. So I’ll leave this here in case someone else finds the issue later on.

I just found a quick way around it.

Damn it feels good to be a gangster.

0 Likes

#2

Could you check if this is a problem only when using --minify or whether this is Hugo related? If it is the former, please post it at https://github.com/tdewolff/minify

0 Likes