3

For my Jekyll site, on each page I am generating BibTeX code, to make it easier to cite. Currently, my template looks like this:

<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>

There's just one problem: for those of you who know BibTeX, I'm missing an entry name. Right after where in my code it says @online{, I need an entry name which is used to refer to entries in a BibTeX database. Now, there are certain limitations on this, for instance it can't contain spaces. In fact, the name of the HTML file that Jekyll generates would be perfect. However, it's unclear to me how to get just this name. The liquid template {{page.url}} will generate something like /2017/02/22/my-page.html, but all I want is just my-page.

1 Answer 1

9

You are looking for the slug attribute:

Slugified title from the document’s filename (any character except numbers and letters is replaced as hyphen)

{{ page.slug }}

will print

my-page 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.