Get Jekyll Collection Item Name (HRU)

I am building a Jekyll site dedicated to GitHub pages and have pre-tested it on a local Windows 8.1 PC with Jekyll 2.5.3, Ruby 2.0.0p598 (2014-11-13) [x64-mingw32] and Gem 2.0.14.

In Jekyll, I have a collection named albums

.

The directory structure for is _albums

similar to the following:

_albums
    foo.md
    bar.md
    baz.md

      

Each file has Front Matter related values ​​such as title

, description

etc.

On some page of the site I am doing a Liquid loop, for example:

{% for album in site.albums %}
    /* need to get album name here */
{% endfor %}

      

Question :

How can I get the bare name for a collection item - for example, foo

or bar

(without an extension containing folders, etc.).

Jekyll documentation says something about a variable name

, but the variable album

has only the following properties: output

, content

, path

, relative_path

, url

, collection

(as well as title

, and description

I set to Front Matter)

album.path

matters like: d:/repo/<project_name>/_albums/foo.md

The workaround I'm using now:

{% assign album_name = album.path | split:"/" | last | split:"." | first %}

      

Could you suggest a better way?

Thanks in advance.

+1


source to share





All Articles