How do I detect the current page in a Jekyll tag plugin?
Turns out we can also do this like:
def render(context)
page_url = context.environments.first["page"]["url"]
Which is not obvious but it doesn't require patching the code.
context['page']
seems to return a hash with most of the properties of the current page, including url
and path
so the actual page object can be retrieved with
context.registers[:site].pages.detect { |p| p.path==context['page']['path'] }