Use relative URLs everywhere and remove <base> tag (#411)

There were a few places still using absolute URLs, including <link rel="icon">
tags, <link rel="alternate"> tags, and nav menu links. In addition, the
presence of a <base> tag caused the browser to absolute-ize all relative
URLs. This also removed "canonifyurls = true" from the example site config.

This is a problem for things like render.com, which will put the site on its
own domain for previews. For example, I have a preview site at
https://houseabsolute-com.onrender.com/. Ultimately this will be served at
https://houseabsolute.com/, but before I switched over I wanted to preview the
site.

The absolute URLs were being generated for https://houseabsolute.com/ because
of my baseURL setting in config and the presence of the <base> tag. This
completely breaks the preview site.
This commit is contained in:
Dave Rolsky
2020-09-28 12:43:06 -04:00
committed by GitHub
parent b3fab506bf
commit 0fb4eafa63
4 changed files with 7 additions and 10 deletions

View File

@@ -15,7 +15,7 @@
{{ with .Site.Menus.main}}
{{ range sort . }}
<li class="navigation-item">
<a class="navigation-link" href="{{ .URL | absLangURL }}">{{ .Name }}</a>
<a class="navigation-link" href="{{ .URL | relLangURL }}">{{ .Name }}</a>
</li>
{{ end }}
{{ end }}