Is it possible to have/use multiple github issue templates on GitHub?

前端 未结 2 1856
夕颜
夕颜 2021-01-16 02:51

As the title say, is there a way to accomplish this?

Like having individual issue templates, one for bug reports ISSUE_TEMPLATE_BUG.md, one for general

相关标签:
2条回答
  • 2021-01-16 03:06

    Since January (25th) 2018, 3 months after this OP (Oct. 2017), this is now possible.

    See "Multiple issue and pull request templates"

    To add multiple issue templates to a repository create an ISSUE_TEMPLATE/ directory in your project root.
    Within that ISSUE_TEMPLATE/ directory you can create as many issue templates as you need, for example ISSUE_TEMPLATE/bugs.md.

    To use those issue templates add ?template= and your template name to the new issue URL.
    Continuing the example, if you create the template bugs.md, you add ?template=bugs.md to the new issue URL, so it becomes /issues/new?template=bugs.md.

    0 讨论(0)
  • 2021-01-16 03:17

    Albeit @VonC's answer is correct, GitHubs integration of issue templates has since improved, so I'll sum the current ways up:

    The easy (new) way

    In the repository's main settings, click on the green button labelled Start template setup within the Issues feature element.
    Then, just follow the instructions provided by GitHub to add, name and edit the issue templates.

    These templates will then be added as Markdown files to the .github/ISSUE_TEMPLATE/ directory within your project root.

    You then can decide whether to edit them directly in your IDE/text editor or directly within GitHub in the same way as stated above.

    If you prefer the official, pictured guide, feel free to use it. ;-)

    The manual (old) way

    Like @VonC explained, just add some markdown files to the .github/ISSUE_TEMPLATE/ directory. You can reference them by adding ?template=filename.md to the new issue URL.

    I'd recommend using a standard template (.github/ISSUE_TEMPLATE.md) with a list of your available templates, like:

    Please switch to **Preview** and select one of the following links:
    
    * [Feature](?template=feature.md)
    * [Bug](?template=bug.md)
    
    Once switched to the correct template, you can save the link as a bookmark. Keep in mind that switching templates will remove all already entered data within this issue.
    

    This allows to get the desired template with just two clicks instead of copy and paste.

    Comparison

    The only difference between the files generated by the new method and the manual (old) ones is a small table at the top containing the name and description of each template.
    You can transform your existing files easily by simply adding these lines at the top:

    ---
    name: Bug report
    about: Use this one for existing problems in the STN, which shouldn't be there.
    
    ---
    

    I would prefer the new way as it's only a wrapper for the old way and you can still use all it's features, like bookmarks with ?template=filename.md and editing via IDE and text editor.

    0 讨论(0)
提交回复
热议问题