.RelPermalink behaves differently in the same template

I have a server running with

hugo server --baseURL http://localhost:1313/tech

and relativeURLs: true in the config.

In a template I have

<a href="{{ .article.RelPermalink }}">
  <div class="hero" style="background-image: url({{ .article.RelPermalink }}index.jpg)">

what gets rendered is

<a href="../../posts/efficient-time-series-data/">
  <div class="hero" style="background-image: url(/posts/efficient-time-series-data/index.jpg)">

I want to swear but instead I just politely ask - why?

Not sure what has changed but now it’s even worse. Both are still different but given that the baseURL is /tech the links that are just <a href="{{ .article.RelPermalink }}"> are now broken as they resolve to “/tech/tech”.

<a href="./tech/posts/efficient-time-series-data/">
  <div class="hero" style="background-image: url(/tech/posts/efficient-time-series-data/index.jpg)">

What is going on?

Setting relativeURLs: false and the site works - except that the links are not relative to .Site.BaseURL.

Further investigations suggest that .RelPermalink does not change with relativeURLs: true but instead that common attributes (like hrefs) get changed in retrospect. Which makes getting the proper .RelPermalink in other places impossible. I haven’t checked the sources yet - but that’s what it looks like.

If that’s really true - that would be pretty bad.

Oh, boy https://github.com/gohugoio/hugo/issues/4355

Seems like attribute rewriting it is…

https://github.com/gohugoio/hugo/blob/a843ca53b5e0f29df9535fa0e88408a63cdc2cd7/transform/urlreplacers/absurlreplacer.go

:frowning: