2014-02-18 61 views
4

我試圖鏈接到html文件名,但它工作,因爲它們在同一個文件夾。如何在鵜鶘博客上鍊接您自己的文章?

但它有可能是另一篇文章將出現在另一個文件夾,因爲ARTICLE_URL格局。示例:

[Title 1](/2014/02/article1.html) 
[Title 2](/2014/01/25/article2.html) 

是否有可能將您自己的文章與參考slug鏈接?比生成的HTML文件名更好的解決方案?

+1

我不認爲現在有一個簡單的方法可以做到這一點。希望有人會爲此創建一個插件。 – mawenbao

回答

9

正如documentation注意到,您可以通過鏈接到其他來源的內容文件:

[a link relative to content root]({filename}/this-is-the-source-file.md) 

......或者......

[a link relative to current file]({filename}../this-is-the-source-file.md) 

鵜鶘將結合你選擇的URL方案,並自動確定鏈接到其他文章的正確方法。

+0

它完美的作品。謝謝。 – jordiburgos

+1

這在編寫reStructuredText而不是Markdown時的工作方式相同:'''這是一個鏈接<{filename} /somefile.rst'_到其他地方.''' – Snorfalorpagus

4

我這樣做的方法是使用save_as元數據標籤指定我自己的段落。所以,如果我有一個名爲my_post.md博客文章,它會是這樣的:

Title: My Blog Post 
save_as: myblogpost.html 

This is the world's most boring blog post. 

這確保我可以在/myblogpost.html鏈接到它。然後,在其他一些博客文章,我可以說:

Title: My Second Blog Post 
save_as: mysecondblogpost.html 

This is the world's second most boring blog post. The most boring blog post is [here]({{ SITEURL }}/myblogpost.html). 

這是一個更加靈活和優雅的解決方案,讓您更細粒度的控制。如果你不使用Pelican作爲博客網站,這是非常重要的。