Edit on GitHub for an 11ty powered website
Adding a link to edit the contents of any page for an 11ty powered website on GitHub is simpler than I thought.[1] Example:
<a href="https://github.com/ulfschneider/ulf.website/edit/master/./content/posts/2021-04-27-edit-on-github-11ty.md">Edit on GitHub</a>
Assuming the above code is inside of an 11ty layout file, here is how to get the correct url for the edit link:
- Provide the url to the GitHub repository containing your website content. In this case
https://github.com/ulfschneider/ulf.website/
. - Add
edit/master/
to the url to indicate you want to edit on the master branch. - Add
{{page.inputPath}}
to the url to have the relative path to the current page inside of your GitHub repository. TheinputPath
variable will be resolved to the concrete file path during build time by 11ty.
https://www.11ty.dev/docs/quicktips/edit-on-github-links/ âŠī¸
Comments