PULL_REQUEST_TEMPLATE.md中GitHub相对内部仓库链接无法正常跳转
I’ve run into this exact frustration with GitHub’s PR template relative links before! The issue boils down to how GitHub resolves relative paths on the PR compare page—your template’s links are being interpreted relative to the compare URL (/owner/repo/compare/...) instead of the repository root.
Here’s how to fix it, depending on your needs:
Option 1: Use a path relative to the PR compare page
Since the PR page lives at/owner/repo/compare/[base]...[head], you need to traverse up one level to get back to the repository root, then point to your file. Use this format:[CONTRIBUTING.md](../blob/main/.github/CONTRIBUTING.md)Replace
mainwith your repository’s default branch name (likemasterif that’s what you use). This will correctly resolve to the file in your repo’s default branch.Option 2: Use an absolute repository path
If you want to avoid worrying about branch names or page context, you can use a path that starts with your repository’s full root path:[CONTRIBUTING.md](/owner/repo/blob/main/.github/CONTRIBUTING.md)This directly targets the file in your repo’s default branch, regardless of where the link is viewed.
Why your previous attempts didn’t work
/owner/repo/.github/CONTRIBUTING.md: GitHub interprets leading slashes as relative to github.com, not your repo, hence the incorrect jump tohttps://github.com/.github/CONTRIBUTING.md..github/CONTRIBUTING.mdor./.github/CONTRIBUTING.md: These resolve relative to the current PR compare page URL, so they append the path to/owner/repo/compare/instead of the repo root.
内容的提问来源于stack exchange,提问作者Clif

