When to Use Relative Links vs Absolute Links in GitHub README Files

Use relative links for internal repository content to ensure portability across forks and renames, while reserving absolute links exclusively for external resources.

Choosing between relative links versus absolute links in GitHub README files determines whether your documentation survives repository moves, forks, and renames without breaking. According to the tiimgreen/github-cheat-sheet repository, relative links are the architectural default for internal content because they resolve dynamically against the repository structure. This guide explains the specific implementation rules found in the source code to keep your Markdown maintainable.

Relative links point to files or headings inside the same repository using paths resolved from the current file's location. The github-cheat-sheet explicitly recommends this approach as the standard for all internal documentation.

As documented in [README.md lines 78-80](https://github.com/tiimgreen/github-cheat-sheet/blob/master/README.md#L78):

"Relative links are recommended in your Markdown files when linking to internal content."

Because GitHub resolves these paths relative to the repository root, they automatically follow the repository if it is renamed, forked, or transferred to a different organization. This eliminates the maintenance burden of updating hardcoded URLs.

Example implementation from the source:

[Link to a header](#awesome-section)
[Link to a file](docs/readme)

Absolute links contain the full URL (e.g., https://github.com/user/repo/blob/master/...) and should only reference external resources outside the current repository. Using absolute links for internal files couples your documentation to a specific URL structure that breaks when the repository changes location.

The github-cheat-sheet warns in [README.md lines 86-88](https://github.com/tiimgreen/github-cheat-sheet/blob/master/README.md#L86):

"Absolute links have to be updated whenever the URL changes (e.g., repository renamed, username changed, project forked). Using relative links makes your documentation easily stand on its own."

Reserve absolute links for third-party websites, external documentation, or resources hosted in separate repositories where relative paths cannot resolve.

Contribution Guidelines and Enforcement

The repository's contribution standards reinforce this linking policy through explicit requirements. The [CONTRIBUTING.md file at line 13](https://github.com/tiimgreen/github-cheat-sheet/blob/master/CONTRIBUTING.md#L13) states:

"Add a link to your section/category to the contents section (use relative links)."

This mandate ensures that the table of contents and all internal navigation remain functional across every fork and clone of the project.

Link selection criteria:

  • Internal files or headings – Use relative links (docs/guide.md, #section). These auto-adjust when the repository moves.
  • External sites or other repositories – Use absolute links (https://...). These target fixed external locations.
  • GitHub Pages rendering – Prefer relative links to ensure compatibility with Jekyll base URL handling.

Summary

Frequently Asked Questions

Relative links continue to function correctly after forking because GitHub resolves them against the new repository's file structure rather than a hardcoded URL. This ensures the documentation remains portable and usable across the entire GitHub ecosystem without requiring any link updates.

Absolute links contain the full URL including the username and repository name (e.g., https://github.com/olduser/oldrepo/blob/master/file.md). When the username or repository name changes, these hardcoded paths become invalid 404 errors, whereas relative links automatically map to the new repository location.

No, relative links cannot point to specific commits because they resolve against the current branch's file tree. To reference a specific commit permanently, you must use an absolute URL including the full commit SHA, such as https://github.com/tiimgreen/github-cheat-sheet/commit/abc123.

Use the file path followed by the anchor hash: [Section Name](docs/other-file.md#section-name). GitHub automatically generates anchors from heading text by converting spaces to hyphens and lowercasing the text, allowing you to link directly to specific sections within the repository structure.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →