I am writing documentation with Github pages (Jekyll) and in one page I want to make link to another. I tried to use {% page_url post-name %}
but with no luck. When I run bundle exec jekyll serve
I get this exception:
Liquid Exception: no implicit conversion of nil into String in docs/page1.md
My posts are in subdirectory docs
and the structure of my documentation looks like this:
CNAME
_config.yml
_includes/
_layouts/
_site/
css/
docs/
page1.md
page2.md
page3.md
imgs/
js/
index.md
The configuration file contains:
safe: true
lsi: false
pygments: true
markdown: kramdown
All pages in docs/
subdirectory contains YAML block:
---
layout: docs
title: Page Two
permalink: /docs/page2/
---
And now, I try to get page url of this page2
:
{% page_url page2 %}
{% page_url docs/page2 %}
{% page_url /docs/page2/ %}
{% page_url /docs/page2.md/ %}
None of this works, I am still getting Liquid Exception
.
So what is the proper way to get url of page in subdirectory?
use the generic link tag: {% link _collection/name-of-document.md %}
so, something like {% link docs/page2.md %}
You should be using the `{% post_url %}' tag, eg:
{% post_url 2010-07-21-name-of-post %}
More details in Jekyll's docs: http://jekyllrb.com/docs/templates/#post-url
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With