# .RelPermalink behaves differently in the same template

**URL:** <https://discourse.gohugo.io/t/relpermalink-behaves-differently-in-the-same-template/22268>\
**Category:** support\
**Created:** [December 12, 2019, 1:28am UTC](https://discourse.gohugo.io/t/relpermalink-behaves-differently-in-the-same-template/22268 "2019-12-12T01:28:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tcurdt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tcurdt/32/6175_2.png) [@tcurdt](https://discourse.gohugo.io/u/tcurdt)\
**Post date:** [December 12, 2019, 1:28am UTC](https://discourse.gohugo.io/t/relpermalink-behaves-differently-in-the-same-template/22268/1 "2019-12-12T01:28:07Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![tcurdt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tcurdt/32/6175_2.png) [@tcurdt](https://discourse.gohugo.io/u/tcurdt)\
**Post date:** [December 12, 2019, 1:37am UTC](https://discourse.gohugo.io/t/relpermalink-behaves-differently-in-the-same-template/22268/2 "2019-12-12T01:37:26Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![tcurdt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tcurdt/32/6175_2.png) [@tcurdt](https://discourse.gohugo.io/u/tcurdt)\
**Post date:** [December 12, 2019, 2:01am UTC](https://discourse.gohugo.io/t/relpermalink-behaves-differently-in-the-same-template/22268/3 "2019-12-12T02:01:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tcurdt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tcurdt/32/6175_2.png) [@tcurdt](https://discourse.gohugo.io/u/tcurdt)\
**Post date:** [December 12, 2019, 2:34am UTC](https://discourse.gohugo.io/t/relpermalink-behaves-differently-in-the-same-template/22268/4 "2019-12-12T02:34:49Z")

</div>

Further investigations suggest that `.RelPermalink` does not change with `relativeURLs: true` but instead that common attributes (like `href`s) 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.

---

<div class="post-metadata">

**Author:** ![tcurdt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tcurdt/32/6175_2.png) [@tcurdt](https://discourse.gohugo.io/u/tcurdt)\
**Post date:** [December 12, 2019, 2:42am UTC](https://discourse.gohugo.io/t/relpermalink-behaves-differently-in-the-same-template/22268/5 "2019-12-12T02:42:41Z")

</div>

Oh, boy [https://github.com/gohugoio/hugo/issues/4355](https://github.com/gohugoio/hugo/issues/4355)

---

<div class="post-metadata">

**Author:** ![tcurdt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tcurdt/32/6175_2.png) [@tcurdt](https://discourse.gohugo.io/u/tcurdt)\
**Post date:** [December 12, 2019, 2:53am UTC](https://discourse.gohugo.io/t/relpermalink-behaves-differently-in-the-same-template/22268/6 "2019-12-12T02:53:59Z")

</div>

Seems like attribute rewriting it is…

[https://github.com/gohugoio/hugo/blob/a843ca53b5e0f29df9535fa0e88408a63cdc2cd7/transform/urlreplacers/absurlreplacer.go](https://github.com/gohugoio/hugo/blob/a843ca53b5e0f29df9535fa0e88408a63cdc2cd7/transform/urlreplacers/absurlreplacer.go)

☹
