Fix double-slashes in URLs and add trailing slash where appropriate #257
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Many links on the site, including nav, are constructed like
href="{{ .Site.BaseURL }}/page"
. As the config baseURL ishttps://uqcs.org/
, this results in a double slash on many links, e.g. renders tohref="https://uqcs.org//about"
. This double-slash also shows in the browser status bar on hover, so looks a bit dodgy.Best practice now (1) (2) seems to be to use the absURL or relURL functions to construct such links, taking care of the required slashes regardless of baseURL having a trailing slash or not and other environmental considerations. I have gone with relURL in this PR. The site previously had a mix of absolute and relative URLs anyway, so this brings them all to relative.
However, should reviewers prefer absolute URLs, there are two options:
canonifyURLs
can be added and set totrue
in config, which will change all URLs on the site, even previously relative, to absolute, and allows easy changing back should there be a future desire to do so.relURL
s in the PR can simply be changed toabsURL
, therefore only affecting links that previously used baseURL.While making this PR, I also noticed that despite links such as
https://uqcs.org/about
, these would be 301 redirected tohttps://uqcs.org/about/
(trailing slash). As Hugo's default pretty URLs mode creates directories for each page, it does not support removing the trailing slash (3) (4). Therefore, I've added the trailing slash to such internal links so that we link straight to the canonical page.