Sub topic 18
Previewing and Maintaining Your README
This chapter assumes you can edit files in a GitHub repository, commit changes, and write basic GitHub Flavored Markdown (GFM): headings, lists, links, code blocks, and tables. It covers how to check a README before it goes live and how to keep it accurate over time.
Why previewing matters
GitHub renders Markdown differently from many local editors. Heading anchors, alerts, Mermaid diagrams, and relative links can look fine in your editor and break on GitHub. Preview in the place readers will see it.
Ways to preview
- The web editor. Open the README on GitHub, select the pencil icon, and switch to the Preview tab. This uses GitHub's own renderer.
- A pull request. Open the pull request's Files changed tab, then choose the Display the rich diff icon on the README file. Reviewers see the rendered page, not just raw text.
- A branch. Push your branch and browse to the README on it. Relative links resolve against that branch, so you can click through them.
- A local editor. Many editors have a Markdown preview. It is fast, but it may not match GitHub for alerts, anchors, or Mermaid.
A pre-merge checklist
Check these items on the rendered page, not the raw text:
- Every heading shows as a heading. A missing space after
#is a common cause of failure. - Code blocks have a language label and keep their indentation.
- Tables have a header row and a delimiter row, with the same column count in each row.
- Relative links open the right file. Click each one.
- Alerts and collapsible sections render. Collapsible sections need blank lines around the Markdown inside them.
- Badges load and show the current status.
Common errors
| Symptom | Likely cause |
|---|---|
| Link to a section does nothing | The anchor does not match the heading. GitHub lowercases the text and replaces spaces with hyphens. |
| Image is missing | The relative path is wrong, or the file is on another branch. |
| List runs into a paragraph | A blank line is missing before the list. |
| Underscores vanish or text turns italic | Special characters need a backslash escape, such as `\_`. |
| Alert shows as a plain quote | The marker, such as `[!NOTE]`, is not alone on the first line of the quote. |
Maintaining the README
A README goes stale when the project changes and the text does not. Build habits that keep it current:
- Treat README edits as part of any change that alters installation, commands, or options.
- Add a README item to your pull request template so reviewers ask the question.
- Rerun the install and usage steps on a clean machine or in a fresh clone every so often.
- Prefer relative links for files inside the repository, so links survive renames of the default branch and work in forks.
- Keep long reference material in a
docs/folder and link to it, so the README stays short. - Search for stale version numbers, removed flags, and dead links when you cut a release.
Exercise
You changed a heading from "Getting Started" to "Quick Start". A link elsewhere in the README still points to #getting-started. What happens, and how do you fix it?
Show answer
The link no longer jumps to the section, because the heading's anchor is now #quick-start. Update the link to #quick-start, then confirm in the GitHub preview that clicking it scrolls to the heading.