Open nk9 opened 2 years ago
Doks can handle this (similar to the TND approach). Not documented that well though — yet 😉
Redirect rules can be appended to /layouts/index.redirects
, which is then built to /public/_redirects
(as you can see configured in your excerpt of config.toml
above).
The default /layouts/index.redirects
:
{{- range $p := .Site.Pages -}}
{{- range .Aliases }}
{{ . }} {{ $p.RelPermalink -}}
{{- end }}
{{- end -}}
# /docs/1.0/prologue/ /docs/1.0/prologue/introduction/
# /docs/1.0/help/ /docs/1.0/help/how-to-update/
# /docs/1.0/ /docs/1.0/prologue/introduction/
# /docs/ /docs/1.0/prologue/introduction/
#
# /docs/0.1/* https://v0-1-0--doks-versioning-poc.netlify.app/docs/0.1/:splat 200
# /docs/0.2/* https://v0-2-0--doks-versioning-poc.netlify.app/docs/0.2/:splat 200
See also the Netlify docs: Redirects and rewrites.
Hugo Aliases are usually handled by <meta http-equiv="refresh" ...>
tags. These have been disabled in ./config/_default/config.toml
with disableAliases = true
, and instead are handled by Netlify's Redirects and rewrites. This is handled automatically and you should continue to add aliases as described in the Hugo documentation.
To be added to the Doks docs!
Oh, excellent, that's just what I was hoping for. Thank you!
Handled by Netlify's Redirects and rewrites in netlify.toml
Thanks, Henk. However, I still don't see anything in the docs about this. And it actually looks like /layouts/index.redirects
is no longer there at HEAD
on main
. And outputFormat.REDIRECTS
has been removed from config/_default/hugo.toml
.
Using outputFormats.REDIRECTS
and the index.redirects
file is a dynamic solution, feasible for large numbers of redirects, in a way that just manually updating the netlify.toml
isn't. Is a built-in, dynamic solution no longer supported?
You're right! Would surely be interesting to re-add/base upon Regis' Redirects Hugo Module with Netlify. I'm thinking of making this a Hyas integration
I have URLs in my site which look like this:
I would like users who navigate to
/episode/15/
to be redirected to the full URL with post slug. While this can be done withalias:
in the front matter, it's cleaner to dynamically generate the Netlify_redirects
file.I have done this on another site with the TND Redirects Netlify module. But it looks like Doks may have its own way to do this already:
config.toml:
I don't see any information in the docs about how to use this output format, though. So I'd like to know if this is already possible, or if I should try to integrate TND Redirects Netlify instead.