Skip to content

Commit 7b08cff

Browse files
Update copilot-instructions.md: Expand Links & References rules (#35979)
* Update copilot-instructions.md: Expand Links & References rules Correct and expand the links and references rules section to properly account for: Cross references with the repo. Non-documentation file links in the repo such as script or code. External links to non-Microsoft sites such as W3C. GitHub links within and outside the dotnet organization. Microsoft Learn content links to other repos. * Update copilot-instructions.md * Apply suggestions from code review Adding guardrex's suggestions. Co-authored-by: Luke Latham <[email protected]> * Update .github/copilot-instructions.md Co-authored-by: Luke Latham <[email protected]> --------- Co-authored-by: Luke Latham <[email protected]>
1 parent ed59ec4 commit 7b08cff

File tree

1 file changed

+34
-12
lines changed

1 file changed

+34
-12
lines changed

.github/copilot-instructions.md

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,40 @@ When creating a PR for an issue:
3131
- If you cannot verify, state that explicitly in your output.
3232

3333
### Links and References
34-
- Use relative links (for example, `../folder/file.md` or `./file.md`) when referencing files within this repository. Do not use absolute URLs or GitHub web links for internal content.
35-
- For external links, always remove any language or culture segment from the URL path (such as `/en-us/`, `/fr-fr/`, `/en/`, etc.).
36-
- Example (Microsoft Learn):
37-
- Original: `https://learn.microsoft.com/en-us/aspnet/core/blazor/`
38-
- Correct: `https://learn.microsoft.com/aspnet/core/blazor/`
39-
- Example (Wikipedia):
40-
- Original: `https://en.wikipedia.org/wiki/ASP.NET_Core`
41-
- Correct: `https://wikipedia.org/wiki/ASP.NET_Core`
42-
- For Microsoft Learn links, also strip the base domain (`https://learn.microsoft.com/en-us`) so only the path remains.
43-
- Example:
44-
- Original: `https://learn.microsoft.com/en-us/aspnet/core/blazor/`
45-
- Correct: `/aspnet/core/blazor/`
34+
- For cross-references to other articles within the AspNetCore.Docs repository:
35+
- Use the xref syntax: `<xref:target-uid>`
36+
- The "target-uid" of the xref syntax is obtained from the `uid` property value in the YAML front matter of the article's markdown file
37+
- Examples
38+
- For a target article `uid` value of `aspnetcore/mvc/overview`, the xref cross-link is `<xref:aspnetcore/mvc/overview>`
39+
- For a target article `uid` value of `blazor/index`, the xref cross-link is `<xref:blazor/index>`
40+
41+
- For non-markdown files (files that don't have the `.md` file extension) within this repository, such as PowerShell scripts and code files:
42+
- Use relative links with the appropriate file extension
43+
- Example: `../build-tools/build.ps1` or `./sample.json`
44+
45+
- For external links to non-Microsoft sites (MDN, W3C, etc.):
46+
- Use absolute URLs
47+
- Remove any language or culture segment from the URL path (such as `/en-us/`, `/fr-fr/`, `/en/`, etc.)
48+
- Example (MDN):
49+
- Original: `https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event`
50+
- Correct: `https://developer.mozilla.org/docs/Web/API/Element/click_event`
51+
52+
- For links to GitHub repositories:
53+
- Use the full URL path
54+
- Example: `https://github.com/maraf/blazor-wasm-react/blob/main/blazor/Counter.razor`
55+
- Example: `https://github.com/dotnet/blazor-samples/10.0/BlazorWebAssemblyReact/blazor/Counter.razor`
56+
- For other Git hosting services or non-Microsoft domains, use the full URL
57+
- Example: `https://gitlab.com/username/repo-name`
58+
59+
- For links to Microsoft Learn content in other repositories:
60+
- Use the relative URL starting with a forward slash
61+
- Don't include the scheme and the host (example: `https://learn.microsoft.com`) and don't include the locale (example: `en-us`)
62+
- Example: For the target Learn website URL `https://learn.microsoft.com/en-us/dotnet/core/introduction`, use the relative URL `/dotnet/core/introduction` for the link destination
63+
64+
- Never use physical .md file paths in published content
65+
- Wrong: `../blazor/index.md` or `/aspnet/core/blazor/index.md`
66+
- Correct: `<xref:blazor/index>`
67+
- Exception: GitHub-only content (such as README files, contributing guidelines, and other repository documentation that isn't published to learn.microsoft.com) should use an absolute URL to the markdown file (`.md` file extension)
4668

4769
## Repository-Specific Guidelines
4870
- Follow the [Microsoft Writing Style Guide](https://learn.microsoft.com/en-us/style-guide/welcome/)

0 commit comments

Comments
 (0)