AleksandrHovhannisyan/aleksandrhovhannisyan.com

Automate Netlify Redirects with 11ty

AleksandrHovhannisyan opened this issue · 3 comments

Automate Netlify Redirects with 11ty

Thanks for the great idea and thorough instructions!

I implemented this for my site and also configured BrowserSync to read the _redirects file so the redirects work locally too: https://github.com/mtsknn/mtsknn.fi/pull/47/files#diff-dfd0229f5460a1b4ac0ded639e55bd0ccaa1f1eedc9f3e79652cf2f2cc3fe4d7

@mtsknn Oh wow, very clever! TIL that you can customize the browsersync behavior in 11ty's server. Thanks for sharing!

Whoops, looks like Eleventy v2 ships with its own dev server and I'm still using v0.12. 🫣 Should have checked first.

FWIW Eleventy Dev Server's repo has an issue about redirect middlewares.

Edit: Eleventy Dev Server reads middlewares from the options object even though it's not mentioned in the docs, so maybe my Browsersync middleware could be easily ported to Eleventy Dev Server. Also, Netlify Redirect Parser would be more robust than my quick _redirects file parser.