github-metadata icon indicating copy to clipboard operation
github-metadata copied to clipboard

Add option to configure branch for github_edit_link

Open runphp opened this issue 2 years ago • 1 comments

The github_edit_link tag currently generates edit links that point to the gh-pages branch by default. This is not ideal when using other default branches like main. It would be helpful to have an option to configure the target branch for github_edit_link, so it can work properly for repositories using non-gh-pages default branches.

Proposal Add a configuration option such as github_edit_branch to _config.yml: yaml github_edit_branch: main This will make github_edit_link generate links pointing to that branch. The user can then set this to main, master or other branches as needed. This will provide more flexibility when using github_edit_link for repositories with different branch setups.

Benefits

  • Works for non-gh-pages default branch
  • Easy configuration in _config.yml
  • More flexibility for users
  • Links point to correct branch for editing

Please consider adding this option in a future release. Let me know if any clarification is needed!

runphp avatar Sep 09 '23 06:09 runphp

As a workaround, I just did this:

{% capture edit_link %}{% github_edit_link %}{% endcapture %}
This site is open source. <a href="{{ edit_link | replace: 'gh-pages', 'main' }}">Improve this page</a>

neilboyd avatar Mar 13 '25 06:03 neilboyd