Some templating, js to rewrite links