Search code examples
jekyllliquidgithub-pages

Jekyll post_url -- what am I missing?


I am using Jekyll and Github pages, testing locally using bundle exec jekyll serve. Everything else works fine so far.

My posts are in a /_posts folder off of the root, and are outputted correctly.

I cannot seem to get {% post_url %} working within posts for other internal posts, no matter what I do.

Example / Question

  • In my _posts folder, I have a post with a file name of 2011-04-14-free-million-dollar-idea-package-carriers-b2b-success.markdown
    • This shows up on my site at [root]/2011/04/free-million-dollar-idea-package-carriers-b2b-success/
  • My config specifies permalink: /:year/:month/:title

I have tried the following references within {% post_url %} from another post, to try to link to the post:

  • 2011-04-14-free-million-dollar-idea-package-carriers-b2b-success
    • Based on the file name of the post, which I thought was what I should be referencing
  • /2011/04/free-million-dollar-idea-package-carriers-b2b-success/
    • Based on the URL that the post actually resides on at my web site
  • 2011/04/free-million-dollar-idea-package-carriers-b2b-success/
    • Without the leading slash
  • /2011/04/free-million-dollar-idea-package-carriers-b2b-success
    • Without the trailing slash
  • 2011/04/free-million-dollar-idea-package-carriers-b2b-success
    • Without either slash

Each one yields the error:

Could not parse name of post [reference] in tag 'post_url'

What am I missing?


Solution

  • If your post file name is 2011-04-14-free-million-dollar-idea-package-carriers-b2b-success.md or .markdown the syntax is :

    [Link text]({% post_url 2011-04-14-free-million-dollar-idea-package-carriers-b2b-success %})