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


source to share


No one has answered this question yet

See similar questions:

3
An elegant way to get a Jekyll collection item by name?
1
Collection of filters by metadata pages

or similar:

1152
Iterating over a collection, avoiding ConcurrentModificationException when disposing of objects in a loop
69
Highlighting double curly braces inside code markdown code in Jekyll
nineteen
Using Liquid Labels in YAML Front Matter Variables
ten
Getting specific item from collection in Jekyll
2
Jekyll collections only show some items
1
Can I use {{page.date}} if the collection has YYYY-MM-DD-filename.md format in Jekyll?
1
Can you list the front array collection variable in Jekyll?
1
Collection of filters by metadata pages
0
Jekyll filter plug-in error "undefined method" - @ 'for: liquidify: Symbol "
0
How to add jekyll based menu item with --unpublished flag?



All Articles
Loading...
X
Show
Funny
Dev
Pics