How to link your own posts?

400 views
Skip to first unread message

Mateusz Łoskot

unread,
Nov 9, 2012, 6:55:59 PM11/9/12
to hak...@googlegroups.com
Hi,

Could anyone give a piece of advice on what is best
practice to realise own posts interlinking in Hakyll?

As Hakyll uses Markdown, I looked at what other popular
static generators do, for example Jekyll/Octopress.
The first [1] option I found is quite obvious and I guess it's generator agnostic:

[This](/posts/2012-12-31-my-own-post)

But, would it work?  I guess it requires explicit .html extension:

[This](/posts/2012-12-31-my-own-post.html)

Doesn't it?

Another option I found [2] is closely tight to Octopress and uses dedicated plugin:

[This]({% post_url 2012-12-31-my-own-post %})

It has pros and cons, but sounds like a neat way to generate interlinks automatically.
Does anyone know if such feature exists or is planned?

Yet another option could be to not to link (parts) sentences directly,
but to list related posts at the bottom, i.e. in section Related Posts.
Similar approach as visible here [3, at the bottom of every post.
I imagine, this could be realised as list of related posts could be
displayed in metadata as list of base names of .markdown files:

related:
- 2012-01-11-hello-world
- 2012-12-31-my-own-post

Obviously, the first option does not require any Hakyll/Haskell hacking.

Any recommendations? Ideas?

I have ~400 posts moved from WordPress I may need to revise
and update, so I'd like to do it right and consistently use in future.


Best regards,
--

Gwern Branwen

unread,
Nov 9, 2012, 7:01:25 PM11/9/12
to hak...@googlegroups.com
On Fri, Nov 9, 2012 at 6:55 PM, Mateusz Łoskot <mat...@loskot.net> wrote:
> As Hakyll uses Markdown, I looked at what other popular
> static generators do, for example Jekyll/Octopress.
> The first [1] option I found is quite obvious and I guess it's generator
> agnostic:
>
> [This](/posts/2012-12-31-my-own-post)
>
> But, would it work? I guess it requires explicit .html extension:
>
> [This](/posts/2012-12-31-my-own-post.html)
>
> Doesn't it?

You can have your HTML pages rendered sans .html suffix and then rely
on a HTML MIME type to get correct rendering (cool URI style). This is
what I do on gwern.net ( http://www.gwern.net/hakyll.hs ); the
original goal was to make my pages work in both Gitit and Hakyll -
Gitit uses extensionless URLs (eg. http://gitit.net/Multilingual )
like pretty much every wiki does but all the example Hakyll sites use
hardwired extensions...

The main challenge was getting reliable uploads with s3cmd to Amazon
S3 where I host. Turned out to require undocumented* behavior (setting
'default_mime_type = text/html' in ~/.s3cfg) and then using
--guess-mime-type and --default-mime-type on uploads. I had been using
--mimetype=text/html, which insisted on uploading my pictures, PDF,
and CSS files as HTML...

* http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=691547

--
gwern

Mateusz Łoskot

unread,
Nov 10, 2012, 6:18:46 AM11/10/12
to hak...@googlegroups.com
On Saturday, 10 November 2012 00:01:47 UTC, gwern wrote:
On Fri, Nov 9, 2012 at 6:55 PM, Mateusz Łoskot <mat...@loskot.net> wrote:
> As Hakyll uses Markdown, I looked at what other popular
> static generators do, for example Jekyll/Octopress.
> The first [1] option I found is quite obvious and I guess it's generator
> agnostic:
>
> [This](/posts/2012-12-31-my-own-post)
>
> But, would it work?  I guess it requires explicit .html extension:
>
> [This](/posts/2012-12-31-my-own-post.html)
>
> Doesn't it?

You can have your HTML pages rendered sans .html suffix and then rely
on a HTML MIME type to get correct rendering (cool URI style). This is
what I do on gwern.net ( http://www.gwern.net/hakyll.hs ); the
original goal was to make my pages work in both Gitit and Hakyll -
Gitit uses extensionless URLs (eg. http://gitit.net/Multilingual )
like pretty much every wiki does but all the example Hakyll sites use
hardwired extensions...

Thanks for the suggestion. It's always good to learn new Hakyll tricks :)
But, I've re-considered it and I'd like to keep the .html extension.
Another very neat solution I found comes from Ian's blog

It has folder-based posts, which I like it very much
and I pratially replicated it on my site (date-based folders only)
Ian's code is mine of great Hakyll tricks, but as complete Haskell
newbie, I don't feel comfortable with complexity of Ian's codes yet ,-)

So, I think a good compromise would be to be able to specify
partial (somewhat relative) URL to posts, without extensions.
For example


[This](2012-12-31-my-own-post)

would be translated to:

[This](/posts/2012-12-31-my-own-post.html)

and

[This](2012/12/31/my-own-post)

would be translated to:

[This](/posts/2012/12/31/my-own-post.html)

and so on.
Reply all
Reply to author
Forward
0 new messages