Are relativeURLs, redirects and pagination fundamentally at odds? I can’t seem to configure my site such that both work consistently. Possibly related to #2199 Investigate RelativeURLs=true and aliases
Let’s say I have relativeURLs
enabled for the scenarios below.
I create a page with an alias and I do not have baseURL set. The generated alias doesn’t seem to bring along the relativeURL goodness:
Frontmatter
---
title: Jobs in the Southeast
url: /work-with-us
aliases:
- /jobs
---
Generated alias page
<!DOCTYPE html>
<html>
<head>
<title>/work-with-us/</title>
<!-- should be ../work-with-us/ -->
<link rel="canonical" href="/work-with-us/"/>
<meta name="robots" content="noindex">
<meta charset="utf-8" />
<meta http-equiv="refresh" content="0; url=/work-with-us/" />
</head>
</html>
Adding baseURL
With baseURL=https://www.fws.gov/southeast
I can get the aliases to work as expected, but then my pagination links break as it starts to mash together baseURL and relative paths.
<!-- redirect works as expected -->
<meta http-equiv="refresh" content="0; url=https://www.fws.gov/southeast/work-with-us/" />
<!-- should be ../articles/ -->
<a href="../southeast/southeast/articles/">1</a>
Customizing alias.html
I figured I could just customize my alias.html page in order to get around this. Unfortunately I can’t access the .Site or $.Site variables to access a site parameter.
<link rel="canonical" href="{{ .Site.Params.base }}{{ .Permalink }}" />
Error: Error building site: template: alias.html:6:36: executing "alias.html" at <$.Site.Params.base>: can't evaluate field Site in type struct { Permalink string; Page *hugolib.Page }