Simple redirects
Imagine this: you are building a new website for your client, but they already have their blog on Tumblr and they are using Assistly to provide support for their world famous product. They of course want to have a "Blog" item in their main menu and of course they also want to have a "Support" item in that menu … and they want to be able to sort the menu items and maybe rename them later … and they might switch from Tumblr to Wordpress soon, so they want to be able to change the link.
You probably don't want to hack the menu to get those damn links in there so here's, where redirects come in handy.
What we are going to do is to add a blog and support folder to your main content folder:
By prepending a number, they will be automatically sorted and added to the main menu.
Now we add a link.txt
to both folders. You can also name that redirect.txt
or anything else, but if it is really a client project I think your clients will understand that best.
The link.txt
has just two fields. The obligatory title field and a link field:
Title: Blog
----
Link: http://ourawesomeproduct.tumblr.com
----
…and…
Title: Support
----
Link: http://assistly.com/ourawesomeproduct
----
It will be easy for your client to change that later.
Now we need a template for that. Add a link.php
file to your template folder:
site/templates/link.php
All we want that template to do, is to redirect the visitor to the link from the content file. So it's just one line of code:
<?php go($page->link()) ?>
This template won't display any HTML to the visitor of that link. The go()
helper function can be used everywhere and does instantly redirect your visitor to the given URL.
Now everytime someone visits http://yourclientsdomain.com/blog
they will be redirected to http://ourawesomeproduct.tumblr.com
and everytime someone visits http://yourclientsdomain.com/support
they will be redirected to http://assistly.com/ourawesomeproduct
. That's pretty neat, right? The menu still stays 100% editable by your client and you don't need to hack anything. Another cool side effect is, that your client now has those nice custom URLs for their external support platform and blog.
Once you've installed such a link.php
template you can even use that to create more custom shortened links for your client. By adding invisible folders to the main content folder you could also create redirects like http://yourclientsdomain.com/facebook
or http://yourclientsdomain.com/someothershortenedlink