Is it possible to retrieve the current path of a page in a middleman file? For instance, if I have a layout file layout.erb
with something like the following:
<%= page.path %>
<%= yield %>
and a test file index.html
:
Testing
then when Middleman rendered the page I would get something like:
/index.html
Testing
Middleman also provides 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 %>
# -> /
Details from Middleman's Middleman::Sitemap::Resource
rubydoc.
http://rubydoc.info/github/middleman/middleman/Middleman/Sitemap/Resource