Sub topic 2
Where Template Files Live
This chapter assumes you know basic Git and GitHub usage (branches, pull requests, issues) and have write or admin access to a repository you can experiment in. GitHub finds templates by path, so a correct file in the wrong place is silently ignored. Learn the paths first, then the content.
The two rules
GitHub applies two rules to every template:
- The file must be at a path GitHub looks in.
- The file must be on the repository's default branch.
Most "my template does not appear" problems break one of these. The final chapter covers diagnosis in detail.
Pull request template locations
A single pull request template is a Markdown file named pull_request_template.md. GitHub looks for it in three places:
- The repository root
- A
docs/folder - A
.github/folder
The filename is case-insensitive, so PULL_REQUEST_TEMPLATE.md also works. Use only one location per repository. Most teams choose .github/ so that all GitHub configuration sits together.
To offer several pull request templates, put them in a directory named PULL_REQUEST_TEMPLATE/, inside one of the same three locations. The multiple-template chapter covers choosing between them.
Issue template locations
Issue templates live in a directory, not a single file:
.github/
├── ISSUE_TEMPLATE/
│ ├── bug_report.yml
│ ├── feature_request.md
│ └── config.yml
└── pull_request_template.mdThe directory must be named ISSUE_TEMPLATE and sit inside .github/. Unlike pull request templates, the root and docs/ locations do not apply to the directory form. The files inside it have three roles:
| File type | Purpose |
|---|---|
| `.md` | Markdown issue template with front matter |
| `.yml` | Issue form, a structured set of fields |
| `config.yml` | Settings for the template chooser, not a template itself |
GitHub also accepts a single legacy ISSUE_TEMPLATE.md file in the root, docs/, or .github/. Prefer the directory, because it supports several templates and the chooser.
How GitHub resolves a template
The default branch rule has a practical consequence. If you create .github/ISSUE_TEMPLATE/bug_report.yml on a feature branch, the issue chooser will not show it until you merge that branch into the default branch. You cannot preview an issue template from an unmerged branch through the normal "New issue" page.
Adding a template
This sequence creates a pull request template and puts it on the default branch. It assumes the default branch is main.
git switch main
git pull
mkdir -p .github
printf '## Summary\n\n## How was this tested?\n' > .github/pull_request_template.md
git add .github/pull_request_template.md
git commit -m "Add pull request template"
git push origin mainOpen a new pull request from any branch. The description box should now start with the two headings.
If your branch protection blocks direct pushes to main, make the change on a branch and merge it through a pull request. The template starts working once the merge lands.
Organization-wide fallbacks
If a repository has no templates of its own, GitHub can fall back to defaults from a public repository named .github in the same organization or account. That repository uses the same layout: the files go in its root, docs/, or .github/ folder, and the issue templates go in an ISSUE_TEMPLATE/ directory. A later chapter covers this in full. For now, remember that a template that appears in one repository but not another often comes from this fallback.
Common mistakes
- Naming the directory
ISSUE_TEMPLATESorissue_template. The nameISSUE_TEMPLATEis exact for issues. - Putting issue templates in the repository root.
- Leaving the file on an unmerged branch.
- Using a different file extension. Issue forms use
.yml, and Markdown templates use.md.
Exercise
You add .github/ISSUE_TEMPLATE/bug_report.yml on a branch called add-templates and open the repository's "New issue" page. The template does not appear. What is the most likely cause, and what fixes it?
Show answer
The file is not on the default branch. GitHub only reads issue templates from the default branch. Merge add-templates into the default branch, and the template will appear in the chooser.