Discussion:
[hakyll] How to make a /YYYY/MM/post-permalink-here/ route structure?
j***@gmail.com
2017-08-25 16:01:30 UTC
Permalink
I'm trying to migrate to Hakyll from Jekyll, but I have to keep my old URL
structure to stay backwards-compatible. My blog posts are at, e.g.
http://my-site.com/2017/03/name-of-blog-post/ (where I guess they're all
actually named index.html). My post filenames are named in the usual Jekyll
way, like 2017-03-27-name-of-blog-post.markdown. Is there a way to
accomplish this? I'm guessing it has something to do with customRoute, but
as a Haskell beginner I'm not sure where to start.
--
You received this message because you are subscribed to the Google Groups "hakyll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hakyll+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Gwern Branwen
2017-08-25 16:58:21 UTC
Permalink
I'm sure a custom route would work, but if it doesn't and if you
aren't deadset on maintaining the old URL structure, you could always
use the Redirect module to set up redirects from all the old URLs to
their new URLs.
--
gwern
https://www.gwern.net
--
You received this message because you are subscribed to the Google Groups "hakyll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hakyll+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'Samuel Tardieu' via hakyll
2017-08-25 18:03:58 UTC
Permalink
Post by j***@gmail.com
I'm trying to migrate to Hakyll from Jekyll, but I have to keep my old
URL structure to stay backwards-compatible. My blog posts are at, e.g.
http://my-site.com/2017/03/name-of-blog-post/ (where I guess they're
all actually named index.html). My post filenames are named in the
usual Jekyll way, like 2017-03-27-name-of-blog-post.markdown. Is there
a way to accomplish this? I'm guessing it has something to do with
customRoute, but as a Haskell beginner I'm not sure where to start.
Here is the custom route I use:

|postPath :: Identifier -> FilePath postPath post = let base =
takeBaseName.toFilePath $ post splitted = splitAll "-" base dir = foldl
(</>) "blog" (take 3 splitted) in dir </> (intercalate "-" $ drop 3
splitted) </> "index.html" |

This gives me
|blog/2014/01/27/apple-users-security-is-not-for-you/index.html| for a
file named |2014-01-27-apple-users-security-is-not-for-you.markdown| for
example. This works by splitting on dashes, integrating the first 3
components into the path, and reassembling the rest with dashes.

​
Sam
--
You received this message because you are subscribed to the Google Groups "hakyll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hakyll+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jonathan Reeve
2017-08-25 18:13:14 UTC
Permalink
Thanks! I got it working by modifying that code a bit into this:

https://github.com/JonathanReeve/hakyll-test/commit/8ef9ab83aa6efaa49a021c925f7e50aeb9f316e4#diff-d969b25c2913c74b1bb1fb5b91807fff

-Jonathan
Jon,
Welcome!
https://www.rohanjain.in/hakyll-clean-urls/
^ this guide might help you. It shows you how to generate an index.html
file in the correct directory per blog post.
Best,
- Wayne
Post by j***@gmail.com
I'm trying to migrate to Hakyll from Jekyll, but I have to keep my old
URL structure to stay backwards-compatible. My blog posts are at, e.g.
http://my-site.com/2017/03/name-of-blog-post/ (where I guess they're
all actually named index.html). My post filenames are named in the
usual Jekyll way, like 2017-03-27-name-of-blog-post.markdown. Is there
a way to accomplish this? I'm guessing it has something to do with
customRoute, but as a Haskell beginner I'm not sure where to start.>
--
You received this message because you are subscribed to the Google
Groups "hakyll" group.> To unsubscribe from this group and stop receiving emails from it,
--
You received this message because you are subscribed to the Google Groups "hakyll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hakyll+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...