Can the taxonomy pagination for page/1 redirect using a relative link?

I’m using a link checker on the static site and it fails in CI when I create a new tag because tags/{new-tag}/page/1 uses the full URL to redirect to https://kylrth.com/tags/{new-tag}, which does not exist online yet. You can see the link checker failing for 64fa1c2 on this GitHub PR on my repo.

Maybe this is a little pedantic, but is there a way within Hugo to rewrite those redirect pages as relative links, rather than the full URL? If not, of course it’s possible to do it with sed.

Hugo generates an alias to the first page of a paginated collection (e.g., public/post/page/1/index.html) using this internal template.

To override the internal template, create layouts/alias.html. For example:

<!DOCTYPE html>
<html{{ with site.LanguageCode | default site.Language.Lang }} lang="{{ . }}"{{ end }}>
  <head>
    <title>{{ .Permalink | relLangURL }}</title>
    <link rel="canonical" href="{{ .Permalink | relLangURL }}">
    <meta name="robots" content="noindex">
    <meta charset="utf-8">
    <meta http-equiv="refresh" content="0; url={{ .Permalink | relLangURL }}">
  </head>
</html>

You must pass .Permalink through the relLangURL function because neither .RelPermalink nor .Page are available in this context.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.