index.redir
inside /layouts used to work but for my new site it seems to fails to generate the redirects.
Is it replaced by a plain _redirects
in the /static root (with _headers
) ?
Or is there some new option to activate it ?
I can’t find anymore any reference on the docs and nothing relevant in discourse. Is it me ?
Thanks for any tip/info.
zwbetz
October 30, 2018, 7:46pm
2
You can have a _redirects
file at the root of your published site, or put your redirects in your netlify.toml
Netlify builds, deploys, and hosts your front end. Learn how to get started, see examples, and view documentation for the modern web platform.
1 Like
Yes thanks, I just changed for that.
But i can (almost ) swear that there was a time where an index.redir generating this.
Anyway thanks for this (new ?) solution.
bep
October 30, 2018, 10:35pm
4
It’s not default, but if you look at the theme that powers gohugo.io there is one. We use Hugo aliases to generate the Netlify redirects file via a custom output format.
3 Likes
Ahhhhhhhhhhhhhhhhh . … yes thanks.
I totally forgot that I also added that part (sure it will not works without it
For other people, i document here this config.toml part.
Again THANKS bep.
[outputs]
home = [ "HTML", "RSS", "REDIR" ]
[mediaTypes]
[mediaTypes."text/netlify"]
suffixes = [""]
delimiter = ""
[outputFormats]
[outputFormats.REDIR]
mediatype = "text/netlify"
baseName = "_redirects"
isPlainText = true
notAlternative = true
and index.redir
# Netlify redirects. See https://www.netlify.com/docs/redirects/
{{ range $p := .Site.Pages -}}
{{ range .Aliases }}
{{ . | printf "%-35s" }} {{ $p.RelPermalink -}}
{{ end -}}
{{- end -}}
1 Like
Some Update for sections
and multi-language
.
site.Pages
only works for current language.
So you have to use {{ range $p := site.AllPages -}}
to also get aliases for sections
and all languages
`