TL;DR: If you write READMEs, issues, or PRs, this cheat‑sheet‑turned‑guide shows exactly how to format things in GitHub. Copy/paste the snippets. Ship better docs.
Why GFM?
GitHub Flavored Markdown (GFM) is the dialect GitHub renders across READMEs, issues, PR descriptions, comments, and wikis. It’s a superset of CommonMark with pragmatic extras—tables, task lists, autolinks, alerts, and math—so you can write clean docs without leaving your keyboard.
Headings & Text
Use # for headings (H1–H6). Underscores or asterisks for emphasis; tildes for strikethrough.
|
1 2 3 4 5 6 7 8 |
# H1 ## H2 ### H3 *italic* or _italic_ **bold** or __bold__ ~~strikethrough~~ |
Pro tip: Keep one # H1 per document (the page title), then start at ##.
Lists (including checklists)
Unordered, ordered, nested, and task lists are all supported. Task lists render clickable checkboxes in issues/PRs.
|
1 2 3 4 5 6 7 8 9 10 |
- unordered - list - nested 1. ordered 2. list - [ ] task to do - [x] task done |
Workflow tip: In PR descriptions, checking off tasks communicates progress without extra comments.
Links, Images, Mentions, and References
Relative links keep READMEs portable across branches. Mentions and shorthand references auto‑link.
|
1 2 3 4 5 6 7 |
[inline link](https://example.com)  [Contributing](docs/CONTRIBUTING.md) <!-- relative link --> @username #123 user/repo#456 user/repo@deadbeef |
#123→ current repo issue/PR.user/repo#123→ other repo issue/PR.user/repo@deadbeef→ commit permalink.
Code & Syntax Highlighting
Use backticks for inline code; triple backticks for blocks. Add a language for highlighting.
|
1 2 3 4 5 6 7 |
Inline `code` ```js // fenced code block with language console.log("hi"); ``` |
Tip: For shell snippets, prefer copy-friendly commands and show the expected output separately.
Tables (lightweight layout)
Alignment uses colons on the separator row.
|
1 2 3 4 |
| Package | Version | |:------- | ------:| | foo | 1.2.3| |
Note: Keep tables small; large ones are hard to maintain in diffs.
Blockquotes
|
1 2 3 |
> Quote line 1 > - Can include **Markdown** |
Use blockquotes for callouts, not multi‑paragraph layout.
Alerts (a.k.a. callouts)
These render with icons and color in GitHub UI.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
> [!NOTE] > Helpful info. > [!TIP] > Pro advice. > [!IMPORTANT] > Must‑know detail. > [!WARNING] > Be careful. > [!CAUTION] > Risk of breakage. |
House style: Use alerts sparingly—one or two per doc to highlight the highest‑value info.
Footnotes
|
1 2 3 4 |
Here’s a fact with a footnote.[^1] [^1]: Footnote text appears at the bottom. |
Great for definitions and citations without cluttering your main flow.
Math (LaTeX)
Inline $...$ or block $$...$$. You can also use a math code fence.
|
1 2 3 4 5 6 7 8 9 10 |
Inline: $E=mc^2$ $$ E = mc^2 $$ ```math alpha + beta ``` |
Tip: If your example needs backslashes (e.g., \int, \frac), some blog engines require escaping inside examples.
Emojis & Shortcodes
|
1 2 |
:rocket: :tada: :penguin: |
Use for tone; avoid replacing important words with emoji.
HTML (when you really need it)
You can mix in safe HTML like <details> and <summary> for collapsible sections. Avoid heavy HTML; GitHub sanitizes unsupported tags.
|
1 2 3 4 5 |
<details> <summary>Click to expand</summary> Hidden content with **Markdown** inside. </details> |
Patterns We Recommend
1) README skeleton
Start every repo with a minimal but complete README.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# Project Name One-liner elevator pitch. ## Quickstart ```bash make setup && make dev ``` ## Configuration - ENV: `FOO_API_KEY` (required) - ENV: `BAR_TIMEOUT` (default: 30s) ## Usage ```bash cli-do-thing --help ``` ## Development - Run tests: `make test` - Lint: `make lint` ## Contributing See [CONTRIBUTING.md](CONTRIBUTING.md). ## License MIT |
2) Issue template snippet
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
### What happened? ### Expected behavior ### Repro steps 1. 2. 3. ### Environment - OS: - Version: |
3) PR description checklist
|
1 2 3 4 5 6 7 8 9 10 11 12 |
## Summary ## Changes - [ ] user‑visible change - [ ] docs updated ## Testing - [ ] unit tests - [ ] manual Fixes #123 |
Accessibility & Style Notes
- Use real headings (not bold lines) for structure and screen reader navigation.
- Don’t rely on color alone; use text labels and icons.
- Keep line length readable (~80–100 chars) for nicer diffs.
- Prefer relative links for intra‑repo docs; use absolute links only when necessary.
Common Pitfalls
- Multiple H1s: pick one title.
- Over‑formatted tables: hard to diff—favor lists or code blocks.
- Screenshots without alt text: always add descriptive alt text.
- Raw HTML everywhere: causes portability issues; stick to Markdown features first.
Copy‑Paste Appendix
A compact snippet set you can drop into any doc.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
### Headings & emphasis # H1 / ## H2 / ### H3 *italic* **bold** ~~strike~~ `code` ### List types - bullet - nested 1. one 2. two - [ ] todo - [x] done ### Links & refs [Link](https://example.com)  @user #123 org/repo#456 org/repo@deadbeef ### Code block ```bash make test ``` ### Table | A | B | |:- | -:| | L | R | ### Alerts > [!TIP] Keep it short. ### Footnote & math Note.[^1] Inline $a^2+b^2=c^2$. [^1]: Footnote text. |
Wrap‑up
GFM hits a sweet spot: expressive enough for real docs, simple enough to type quickly. With a few conventions and snippets, your READMEs, issues, and PRs will be easier to read, search, and maintain.




