You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

修改GitHub Issue模板选择器的按钮文本与行为

Customizing Button Text and Same-Tab Opening for GitHub Issue Templates

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 the template= parameter in your URL (e.g., bug_report.yml must exist for ?template=bug_report.yml).
  • Confirm the relative path is correctly structured—if your config.yml is in .github/ISSUE_TEMPLATE/, ../../issues/new will correctly navigate to the repository’s issue creation page.

内容的提问来源于stack exchange,提问作者Yash Chowdhary

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:52:53