2013-11-25 23 views
3

我正在用Github頁面(Jekyll)編寫文檔,並在一個頁面中我想鏈接到另一個頁面。我試圖使用{% page_url post-name %}但沒有運氣。當我運行bundle exec jekyll serve我得到這個異常:如何獲取液體(Jekyll)網頁的url

Liquid Exception: no implicit conversion of nil into String in docs/page1.md 

我的帖子是在子目錄docs和我的文檔的結構是這樣的:

CNAME 
_config.yml 
_includes/ 
_layouts/ 
_site/ 
css/ 
docs/ 
    page1.md 
    page2.md 
    page3.md 
imgs/ 
js/ 
index.md 

該配置文件包含:

safe: true 
lsi: false 
pygments: true 
markdown: kramdown 

所有頁面在docs/子目錄中包含YAML塊:

--- 
layout: docs 
title: Page Two 
permalink: /docs/page2/ 
--- 

而現在,我試圖讓這個page2的頁面網址:

{% page_url page2 %} 
{% page_url docs/page2 %} 
{% page_url /docs/page2/ %} 
{% page_url /docs/page2.md/ %} 

無的這個作品,我仍然得到Liquid Exception

那麼什麼是正確的方式來獲取網頁在子目錄中的網址?

+0

你可以嘗試設置'文檔:在您的網站url'你'_ config.yml'文件,然後使用與「page2」連接的'site.docs'來獲取頁面的URL。這很醜陋,你 - 你確定沒有任何東西可以使用嗎?[jekyll變量](http://jekyllrb.com/docs/variables/)? – agarie

回答

2

使用通用的鏈接標籤: {%鏈接_collection/name-of-document.md%}

所以,像 {%鏈接的文檔/ page2.md%}