Disable redirect pages or add my own template

Is there a way to either disable redirect pages (like /tags/tagname/page/1/index.html) or add my own template for Hugo to override what it outputs?

I am in the process to configure an HTML validator and receive lots of errors to these pages, while at the same time doing redirects via headers, so the files created are not being used on the server and the errors are irrelevant (mostly about language attributes).

You will say “just ignore those files”, but I fail to have an idea how to configure what files to ignore. They are all index.html files which doesn’t help indicate which files to ignore.

I could probably “just” search for all files that have a <meta http-equiv="refresh" in them. Just asking before I go that route :wink: It might be just some milli seconds that I loose.

On a side note, those redirect files have one single function, to tell the browser to redirect via a special meta tag that indicates a header, here is a sample content:

<!DOCTYPE html>
<link rel="canonical" href=""/>
<meta name="robots" content="noindex">
<meta charset="utf-8" />
<meta http-equiv="refresh" content="0; url=" />

the following parts could be removed to shave off some more bits without making the html invalid:

  • the title tag (unnecessary)
  • the link-rel-canonical tag (not used because it’s a redirect and google is not interested in listing this page)
  • the meta-robots tag (not used because it’s a redirect and google is not interested in listing this page)
  • the meta-charset tag (indicating the content encoding of the file, which is a redirect, which results in the file not being shown in the browser. so not used for anything.)
  • the slash at the end of the meta-http-equiv tag (unnecessary within HTML5)

PS: for what it’s worth, the bash line to delete all files with refresh-redirects is this one:

grep -lrIZ http\-equiv\=\"refresh public | xargs -0 rm -f --

The only setting that I am aware of is disableAliases.

However I am not sure whether it is applicable in your case, as Hugo creates the aliases for taxonomy terms automatically without user input.

Rethinking it, I would say that my header solution probably ignores these specific 1st page redirects too. I think for the purpose of checking for HTML validity I probably have to go the way of creating the site, then removing all redirect files with a bash line like above, then auditing what’s left… That specific generated site won’t go to production in the end.

On the other side, disableAliases seems like a good way to cut off some bytes if redirecting of posts is done via plugin. It won’t kill list-page-redirects, but all the other fixed-urls-redirects.