Mark Pearl

Get path of current page

You have access to the current_page variable. current_page.path is the source path of this resource (relative to the source directory, without template extensions) and current_page.url is the path without the directory index (so foo/index.html becomes just foo).

<%= current_page.path %>
# -> index.html
<%= current_page.url %>
# -> /

The following…

<% link_to('/yourlink.html', { :class => 'your-class another-class', :"data-icon" => 'd' }) do %>Link Text<% end %>

Will render the following html…

<a class="your-class another-class" data-icon="d" href="yourlink/">Link Text</a>

See original thread


Understanding Middleman - the static site generator for faster prototyping
Github Middleman Project
Middleman App
Great Middleman Summary

blog comments powered by Disqus

Want to get my personal insights on what I learn as I learn it? Subscribe now!