Markdown Tricks for Cleaner Docs
I've written a lot of documentation over the years, and I've learned that Markdown is more powerful than most people give it credit for. Beyond the basics of headings, bold, and links, there are a few tricks that make my docs cleaner, more readable, and easier to maintain. Here are the ones I use constantly.
Use Tables Wisely
Tables are great for structured data, but they can get messy. The key is to keep them simple and align the pipes for readability, though you don't have to align them perfectly for Markdown to render. However, aligning them makes the source easier to scan. I also avoid using tables for complex layouts; they're best for comparisons or reference data.
| Feature | Status | Notes |
|---------|--------|-------|
| Search | Done | Uses Elasticsearch |
| Export | Beta | CSV and JSON |
| Import | Planned| - |
Task Lists for Progress Tracking
Task lists are a lifesaver for tracking progress in docs, especially in READMEs or project plans. They're simple: use - [ ] for unchecked and - [x] for checked. Many platforms render them with checkboxes, making them interactive.
- [x] Set up project structure
- [x] Implement authentication
- [ ] Write API docs
- [ ] Add tests
Collapsible Sections
Long docs can be intimidating. Collapsible sections let you hide details until the reader needs them. This works on GitHub and many other platforms. Use the <details> and <summary> HTML tags.
<details>
<summary>Click to expand the installation guide</summary>
Here are the detailed steps...
bash
npm install my-package
</details>
markdown
Note the blank line after the </summary> and before the content; it's needed for proper rendering.
Anchor Links for Navigation
If your doc is long, anchor links help readers jump to specific sections. Most Markdown processors automatically generate anchors from headings. You can link to them using #heading-text (with spaces replaced by hyphens, and lowercase). For example, linking to a section called "Installation Steps" would be #installation-steps.
[Go to Installation](#installation-steps)
## Installation Steps
You can also add custom anchors using HTML, but I rarely need that unless the heading text is unusual.
Code Blocks with Syntax Highlighting
Always specify the language for code blocks. It improves readability and helps with syntax highlighting. But there's a trick: you can also add a title or filename using title= inside the fences. This is supported on many platforms like GitHub and GitLab.
``javascript title="example.js"Hello, ${name}!`;
function greet(name) {
return
}
This shows the filename in the code block header, which is great for documentation.
### Blockquotes for Notes and Warnings
Blockquotes are not just for quotes. They're perfect for callouts like notes, tips, and warnings. You can add bold labels to make them stand out.
```markdown
> **Note:** This feature is experimental.
> **Warning:** Back up your database before upgrading.
Some platforms support special admonition syntax, like GitHub's > [!NOTE] and > [!WARNING], which render with colored boxes. Use those if available.
Escaping Characters
Sometimes you need to show Markdown characters literally. Use backslashes to escape them. For example, to show an asterisk without making it bold, write \*. This is handy when writing about Markdown itself.
To make text bold, use two asterisks: \*\*bold\*\*
Nested Lists
Nested lists can be tricky because indentation matters. Use two or four spaces (be consistent) to create sub-items. I prefer four spaces for clarity.
- Item 1
- Sub-item A
- Sub-item B
- Item 2
Horizontal Rules for Visual Separation
A horizontal rule (---) is great for separating sections without using headings. It's a clean visual break. Just make sure to add a blank line before and after to avoid turning it into a heading (like --- on the line right after text).
Use Relative Links for Internal Docs
When linking between files in a repo, use relative links instead of absolute URLs. This makes your docs portable and easier to move. For example, [API docs](./api.md) instead of [API docs](https://example.com/api). This is a small habit that pays off big when you reorganize your project.
Keep It Simple
Finally, the best trick is to not overuse these features. Markdown is meant to be readable in plain text. If you find yourself nesting too many blockquotes or using tables for layout, step back and simplify. Clean docs are about clarity, not showing off every feature.
These tricks have made my documentation much more maintainable and user-friendly. Try them out and see which ones work for your workflow.
Top comments (0)