Sub topic 13
Adding badges
A badge is a small image, usually a status label, that sits near the top of a README. This chapter assumes you can already write Markdown links and images and know what a GitHub Actions workflow file is. It covers how badges are built, where they come from, and how to keep them useful.
What a badge is
A badge is an ordinary Markdown image whose URL points to a service that generates the picture on request. Because the service renders it each time the page loads, the badge can show live information such as whether the latest build passed.
The image syntax is . A badge adds nothing beyond that.
# Project Name

One sentence describing what the project does.Here ci.yml is the file name of a workflow in .github/workflows/. GitHub draws the badge as passing, failing, or no status.
Making a badge clickable
A plain badge is only a picture. To make it open a page, wrap the image in a link: [](target-url).
[](https://github.com/OWNER/REPO/actions/workflows/ci.yml)The outer brackets and parentheses are the link. The inner part is the image. A reader who clicks the CI badge lands on the workflow's run history.
Static and dynamic badges
Badges come in two kinds.
| Kind | Example source | What it shows |
|---|---|---|
| Workflow status | GitHub Actions `badge.svg` | Pass or fail of the latest run |
| Dynamic | shields.io | Package version, downloads, license, and more |
| Static | shields.io `badge/label-message-color` | Fixed text you choose |
Shields.io is a third-party service that builds badges from a URL. A static badge needs no data source.
Dynamic badges read data from a registry or from GitHub. For example, the URL https://img.shields.io/npm/v/PACKAGE shows the current version of an npm package.
Choosing and placing badges
Put badges directly under the title, on one line or a few short lines. Keep them to facts a reader uses: build status, latest version, license. A row of fifteen badges pushes the description below the fold and makes the page harder to read.

Adding ?branch=main limits the CI badge to runs on that branch. Without it, a failing feature branch can turn the badge red for everyone.
Common errors
- Wrong workflow file name. The URL must match the file in
.github/workflows/exactly. A mismatch shows "no status". - Empty alt text. Screen readers announce the alt text, so write
CIorLicense: MIT, not nothing. - Stale information. A badge that hard-codes a version number in a static URL never updates. Use a dynamic source where one exists.
- Dependence on an outside service. If shields.io is down, those images do not load. The README must still make sense without them.
Exercise
Write the Markdown for a CI badge that shows the status of the main branch for workflow file test.yml in repository acme/widget, and that opens the workflow page when clicked.
Show answer
[](https://github.com/acme/widget/actions/workflows/test.yml)