Mike Slinn
Mike Slinn

jekyll_basename_dirname

Published 2020-10-03. Last modified 2023-05-18.
Time to read: 1 minutes.

This page is part of the jekyll_plugins collection.

Jekyll_basename_dirname is a Jekyll plugin that provides 3 filters that return portions of a string: basename, dirname and basename_without_extension.

  • basename – Filters a string containing a path, returning the filename and extension.
  • dirname – Filters a string containing a path, returning the portion before the filename and extension.
  • basename_without_extension – Filters a string containing a path, returning the filename without the extension.

Installation

Jekyll_basename_dirname is packaged as a Ruby gem. Add the following line to your Jekyll project’s Gemfile.

Shell
group :jekyll_plugins do 
  gem 'jekyll_basename_dirname'
end 

Install the jekyll_basename_dirname gem in the usual manner:

Shell
$ bundle

Syntax

Shell
{{ "blah/blah/filename.ext" | dirname }} => blah/blah
{{ "blah/blah/filename.ext" | basename }} => filename.ext
{{ "blah/blah/filename.ext" | basename_without_extension  }} => filename


* indicates a required field.

Please select the following to receive Mike Slinn’s newsletter:

You can unsubscribe at any time by clicking the link in the footer of emails.

Mike Slinn uses Mailchimp as his marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp’s privacy practices.