Skip to content

Instantly share code, notes, and snippets.

@jtanguy
Created January 13, 2014 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtanguy/8401281 to your computer and use it in GitHub Desktop.
Save jtanguy/8401281 to your computer and use it in GitHub Desktop.
Redirects within hakyll
match "redirects.txt" $ do
route $ constRoute ".htaccess"
compile $ makeItem "" >>=
loadAndApplyTemplate "templates-htaccess" myCtx
where
myCtx = metadataField `mappend`
defaultContext
---
redirects:
- old: "/my/old/path.html"
new: "/my/new/path.html"
- old: "/my/other/old/path.html"
new: "/my/new/other/path.html"
---
$for(redirects)$
Redirect 301 $old$ $siteRoot$$new$
$endfor$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment