# relURL doesn't output the base path

**URL:** <https://discourse.gohugo.io/t/relurl-doesnt-output-the-base-path/48882>\
**Category:** support\
**Created:** [March 17, 2024, 5:06pm UTC](https://discourse.gohugo.io/t/relurl-doesnt-output-the-base-path/48882 "2024-03-17T17:06:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tom\_Durand](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tom_durand/32/14460_2.png) [@Tom\_Durand](https://discourse.gohugo.io/u/Tom_Durand)\
**Post date:** [March 17, 2024, 5:06pm UTC](https://discourse.gohugo.io/t/relurl-doesnt-output-the-base-path/48882/1 "2024-03-17T17:06:05Z")

</div>

Hi,  
I finally got the gist of my github page.  
There is an issue with just two links (seemingly) out of the whole site. The code to produce them is:

```auto
{{with relURL "/fonts/norse.woff2"}}
<style>
@font-face {
	font-display: optinal;
	font-family: "norse";
	src: url('{{.}}') format("woff2");
}
</style>
<link rel="preload" href="{{.}}" as="font" type="font/woff2" crossOrigin>
{{end}}

```

the result is:

```auto
<style>@font-face{font-display:optinal;font-family:norse;src:url(/fonts/norse.woff2)format("woff2")}</style><link rel=preload href=/fonts/norse.woff2 as=font type=font/woff2 crossorigin>

```

my BaseURL is: `BaseURL = “[https://perso-domain.github.io/website/](https://perso-domain.github.io/website/)”  
So why is the base path not in the links’ url ? Is this a bug ? I thought that was the purpose of relURL ?

> {{\< relurl “quez.html” \>}} → /foo/bar/baz/quez.html  
> {{\< relurl “/quez.html” \>}} → /foo/bar/baz/quez.html  
> {{\< relurl “…/quez.html” \>}} → /foo/bar/quez.html  
> {{\< relurl “./quez.html” \>}} → /foo/bar/baz/quez.html

I know there are plenty of issues raised about relURL… None simple to understand  
Thanks

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [March 17, 2024, 5:13pm UTC](https://discourse.gohugo.io/t/relurl-doesnt-output-the-base-path/48882/2 "2024-03-17T17:13:19Z")

</div>

`relURL` and friends behave differently (intentionally) depending on whether the path begins with a slash.

[https://gohugo.io/functions/urls/relurl/#input-does-not-begin-with-a-slash](https://gohugo.io/functions/urls/relurl/#input-does-not-begin-with-a-slash)

In most cases you should omit the leading slash.

---

<div class="post-metadata">

**Author:** ![Tom\_Durand](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tom_durand/32/14460_2.png) [@Tom\_Durand](https://discourse.gohugo.io/u/Tom_Durand)\
**Post date:** [March 17, 2024, 5:17pm UTC](https://discourse.gohugo.io/t/relurl-doesnt-output-the-base-path/48882/3 "2024-03-17T17:17:08Z")

</div>

Can you tell what was the reason behind this highly confusing design ?

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [March 17, 2024, 5:27pm UTC](https://discourse.gohugo.io/t/relurl-doesnt-output-the-base-path/48882/4 "2024-03-17T17:27:10Z")

</div>

It could have gone either way. There are cases when you want the resulting path to be relative to the server root (e.g., `https://example.org`), and (more commonly) relative to the base URL (e.g., `https://example.org/subdir/`), which may or may not be the server root.

I think it makes more sense to have the leading slash resolve to the server root.

The alternative was to create two more functions (e.g., relUrlServerRoot, relLangURLServerRoot, or something worse).
