修改GitHub Issue模板选择器的按钮文本与行为
I’ve looked into how create-react-app handles this exact setup, so here’s how you can solve both of your requirements:
1. Setting Custom Button Text
You’re actually already on the right track with the context.button-text field in your config.yml! GitHub does support this configuration—even if it’s not prominently highlighted in some versions of the docs.
Just define your custom text directly in the context object for each contact link, like this:
blank_issues_enabled: true contact_links: - name: Bug Report url: <URL_OF_TEMPLATE> about: Something isn't working as expected? Create a report to help us improve. context: button-text: Report a Bug # Replace with your preferred button text - name: Feature Request url: <URL_OF_TEMPLATE> about: Suggest a new idea or feature for <REPO>. context: button-text: Request a Feature
After saving this, refresh your repository’s Issues page (or clear your browser cache if needed)—your custom button text should show up immediately.
2. Opening Templates in the Same Tab
By default, GitHub opens contact_links URLs in a new tab. To override this and load the template in the current tab, swap the full absolute URL for a relative path to your issue template.
Instead of using a full URL like https://github.com/your-username/your-repo/issues/new?template=bug_report.yml, use a relative path that resolves to your repository’s issue creation page. For a config.yml stored in .github/ISSUE_TEMPLATE/, the relative path would be:
contact_links: - name: Bug Report url: ../../issues/new?template=bug_report.yml # Relative path instead of full URL about: Something isn't working as expected? Create a report to help us improve. context: button-text: Report a Bug
This is exactly the trick create-react-app uses. The relative path tells GitHub to load the link within the same tab instead of spawning a new one.
Quick Checks to Ensure It Works
- Double-check that your template file exists in
.github/ISSUE_TEMPLATE/and matches thetemplate=parameter in your URL (e.g.,bug_report.ymlmust exist for?template=bug_report.yml). - Confirm the relative path is correctly structured—if your
config.ymlis in.github/ISSUE_TEMPLATE/,../../issues/newwill correctly navigate to the repository’s issue creation page.
内容的提问来源于stack exchange,提问作者Yash Chowdhary

