2017-02-23 62 views
1

对于我的Jekyll网站,在每一页上我都会生成BibTeX代码,以便于引用。目前,我的模板看起来是这样的:如何获得页面文件名称,减去Jekyll中的扩展名(即基本名称)?

<code> 
    % BibTeX Code 
    % Copy and paste the following code into your .bib file to cite this article: 

    @online{ 
     title="{{ page.title | escape }}", 
     author="{{ page.author | escape }}", 
     organization="{{ site.title | escape }}", 
     date="{{ page.date | date: "%Y-%m-%d" }}", 
     urldate="{{ site.time | date: "%Y-%m-%d" }}", 
     url="<!-- website domain name here -->{{page.url}}" 
    } 
</code> 

这里有一个问题:对于那些你们谁知道中文提供,我错过了一个条目名称。在我的代码中,在@online{之后,我需要一个条目名称,用于引用BibTeX数据库中的条目。现在,这有一些限制,例如它不能包含空格。事实上,Jekyll生成的HTML文件的名称是完美的。然而,我不清楚如何得到这个名字。液体模板{{page.url}}将生成类似/2017/02/22/my-page.html的东西,但我想要的仅仅是my-page

回答

2

您正在寻找slug属性:

从文档的文件名

Slugified标题(除 数字和字母的任何字符被替换为连字符)

{{ page.slug }} 

将打印

my-page 
相关问题