Andrew Whipple

The most sensational, inspirational, celebrational, muppetational

Discovering Features Of Amelie!

Published 09/16/2017

This morning I discovered something interesting: I had set up years ago a handful of redirects with Hover, my domain registrar of choice.

Of course, those have been broken for a long time, entirely because when switching the DNS over to my hosting provider, Hover no longer has control to handle these redirects. Whoops-a-daisy.

And the way Amelie, the engine I built to power this site, handles routing and such, urls like "andrewwhipple.com/xyz" first check if there is a single page (like /about and such) and if there isn't, 404s.

So in order to do forwards like I had in Hover (for example, andrewwhipple.com/youtube forwarding to my Youtube page) I'd need to either futz with the Nginx proxy I have set up in front of my actual app servers, or figure out some way to add more routing rules in the router for pages in the engine itself.

Neither super fun.

BUT! Because Amelie pages start as Markdown files that get HTML-ified and plopped into a template, they basically are prettier version of html files. So anything you can do in HTML, you can do in an Amelie page. Including adding in Javascript!

So, all it took was making a new markdown page with the filename for the short url I wanted to use (ex, youtube.md in the example above), and making that page just have a simple <script> tag, and adding in: window.location.href = "newUrl";

Voila! Auto redirect at the site level, rather than in the DNS or in the engine. And it doesn't require mucking around with the engine code or the Nginx proxy. Just making a new page with one line of code, throwing it into dropbox, and the redirect is live.

And it's fun because this is the same kind of hacking around and discovering cool features I do in other people's projects, and this time I get to do it in my own project!

Neat y'all!

-Andrew W.