How to create "Edit on Github" links, while disturbing the theme as little as possible?

You can do that with different ways, for example:

  • add a repository parameter in your config:
[params]
  repository = "https://github.com/group/repo"

You have to change both “group” and “repo” in this URL.

  • add this line in your template(s):
<a href="{{ .Site.Params.repository }}/edit/main/content/{{ .File.Path }}">Edit this page</a>

As you can see, /edit/main/ depend on GitHub and on the name of your main branch. And content is the folder of your content. You must tweak it to suit the template.

1 Like