---
myst:
  html_meta:
    "description": "Add a towncrier news fragment to the right package of a repository, preview the changelog, and check that nothing is missing."
    "property=og:description": "Add a towncrier news fragment to the right package of a repository, preview the changelog, and check that nothing is missing."
    "property=og:title": "Add news fragments"
    "keywords": "Plone, repoplone, towncrier, news fragment, changelog"
---

(how-to-add-news-fragments)=

# Add news fragments

This guide shows you how to add a news fragment to the package a change belongs to.
It also shows how to check the fragments before you push.

(how-to-add-news-fragments-where)=

## Find where the fragment goes

Make your change first.
Then ask repoplone which parts of the repository need a fragment.

```shell
uvx repoplone changelog check
```

The command compares your branch with `origin/main`, including uncommitted and untracked files.
It prints a table with one row per {term}`area`: each package, and the repository itself.
For each area missing a fragment, it names the news folder to add it to.

```text
Missing a news fragment:
- fake.distribution: add one to backend/news/
```

To compare with another branch, pass it with `--compare-with`.

```shell
uvx repoplone changelog check --compare-with origin/1.x
```

(how-to-add-news-fragments-write)=

## Write the fragment

Create a file in that news folder, named after the issue and the type of change.

```shell
echo 'Fix the search results order. @yourhandle' > backend/news/42.bugfix
```

The name has two parts.
The first part is the issue number.
For a change without an issue, use `+` and a short slug, such as `+search-order.bugfix`.
The second part is the type of change.
The valid types are the ones the area's towncrier configuration lists, such as `feature`, `bugfix`, or `internal`.

The content is the changelog entry.
Write one or two sentences in the present tense, and end with the handle of the author, as Plone projects do.

(how-to-add-news-fragments-preview)=

## Preview the changelog

Show the changelog that the next release would write.

```shell
uvx repoplone changelog preview
```

The draft shows the new version, with one section per package and one for the repository.
It writes nothing.

(how-to-add-news-fragments-check)=

## Check again

Run the check once more.

```shell
uvx repoplone changelog check
```

It exits with `0` and prints `Every area that changed has a news fragment.` when every area that changed has its fragment.

```{seealso}
- {doc}`/explanation/news-fragments`, for how areas and fragments work.
- {doc}`check-news-in-ci`, to run the check on every pull request.
```
