[Hlelp] Getting the date from file name

Hi,

I would like to add Edit on github button for my posts. When user clicks on the button, it should take user to the respective page on github in the edit mode.

As posts in the _posts folder starts with YYYY-MM-DD format, is there any way I could read the date (or entire file name) from the file name so that I can integrate that into my post?

Thanks in the advance.

TL/DR: If you use page.path you don’t have to infer the date, it will give you the raw file path to the post or page. Then you can do something like:

<a href="https://www.github.com/{{ site.github_username }}/{{ site.git_repo }}/blob/master/{{ page.path }}">Edit on GitHub</a>