Why and How to Add Pull Request Templates to Your GitHub Project

Why #

Pull request templates are a great way to give more structure to your open source project. Templates can be used to standardize the information that is included in pull requests, such a checklist of criteria that need to be fulfilled before it can be merged. This makes it easier for new contributors who get an understanding of the expectations of new code being merged into the project.

They can also save time for maintainers as they make it easier to access the appropriateness of new pull requests that are opened and what the purpose of them are. Maintainers can refer back to the template if it is deleted or only partially filled in. It also means when maintainers (or just people browser the project) look back, there is a standardised history of changes that can be reviewed.

How #

You will need to create a folder called .github in the root directory of your project.

In here you need to create a file called pull_request_template.md. This is is the file we need to edit to create our pull request template. The template file is just markdown, so we can take advantage of markdown's features to make a great template. The following sections are some examples of things you can do.

Comment #

Comments can be useful for helping give contextual information in the template, without it appearing in the actual pull request itself.

### Issue:

<!-- A comment looks like this. Lets put our body of the issue here -->

Bullet points #

Bullet points can be useful for making sure people list out key pieces of information:

- Documentation has been updated

Checkboxes #

### Issue:

- [ ] There is an existing issue ticket open for this PR
- [ ] I have updated the relating documentation to reflect my changes

Example #

Here is an example of a pull request template:

## Description

Please describe your changes and the problem you are solving.

## Changes Made

- List the changes you made here
- Be specific and clear
- Include any relevant details

## Checklist

- [ ] Tests have been added or updated
- [ ] Documentation has been updated
- [ ] The code follows the project's style guide
- [ ] Any relevant configuration files have been updated

## Screenshots (if applicable)

Please attach any relevant screenshots that show the changes made.

This template includes sections for describing the changes made, listing the changes, providing a checklist of things that need to be done before the pull request is ready to be reviewed, and including screenshots or additional context. It's a simple template but it provides a sensible starting point for where you might begin. Depending on the project's needs and complexity, you can add more sections, or remove some that may not be necessary.

Published