doks icon indicating copy to clipboard operation
doks copied to clipboard

Document dynamic generation of Netlify `_redirects` file

Open nk9 opened this issue 2 years ago • 5 comments

I have URLs in my site which look like this:

/episode/15/the-boy-and-the-whale

I would like users who navigate to /episode/15/ to be redirected to the full URL with post slug. While this can be done with alias: 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:

home = ["HTML", "RSS", "REDIRECTS", "HEADERS"]

# add output format for netlify _redirects
[outputFormats.REDIRECTS]
mediaType = "text/netlify"
baseName = "_redirects"
isPlainText = true
notAlternative = true

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.

nk9 avatar Jan 10 '22 13:01 nk9