# Add Author Pages to a Wagtail Blog

Yes. An agent adds an authors/<slug>/ route to the blog index, a slug on the Person snippet with a data migration, links author names, writes tests, and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-author-pages/wagtail/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads how authors are modelled before it adds a URL for them. In a site shaped like wagtail/bakerydemo, `requirements/base.txt` pins `wagtail>=8.0,<8.1` on `Django>=6.0,<6.1`. `bakerydemo/blog/models.py` links a `BlogPage` to people through `BlogPersonRelationship`, a `ParentalKey` with `related_name="blog_person_relationship"` and a `ForeignKey` to `base.Person`, and `BlogPage.authors()` returns the live ones. `BlogIndexPage` already mixes in `RoutablePageMixin` for tags: `@route(r"^tags/([\w-]+)/$", name="tag_archive")` renders `blog/blog_index_page.html` with `tag` and `posts`, redirects to the index with a message when the tag does not exist, and `get_posts(tag=None)` does the filtering. The `Person` snippet in `bakerydemo/base/models.py` has `first_name`, `last_name`, `job_title` and `image`, draft state and revisions, and no slug. In the templates, `blog/blog_page.html` prints each author's avatar and name without a link, and `includes/card/blog-listing-card.html` prints `{{ author }}` after the date, also unlinked.

It adds a `slug` field to `Person`, unique and filled in `save()` from `slugify(f"{first_name} {last_name}")` when blank, and writes two migrations in `bakerydemo/base/migrations`: one that adds the field nullable, a data migration that fills every existing person and appends the primary key where two people share a name, and the field made unique and required in the same pair. The `Person.panels` get a `FieldPanel("slug")` so editors can change it, and `api_fields` gains `APIField("slug")` so the pages API exposes it. Then `BlogIndexPage` gets `@route(r"^authors/([\w-]+)/$", name="author_archive")`: it looks up a live `Person` by slug, falls back to the same message-and-redirect the tag route uses, and renders `blog/blog_index_page.html` with `author` and the posts from `get_posts(author=person)`, which gains an `author` keyword that filters on `blog_person_relationship__person`.

The template already handles a `tag` heading; the agent adds the matching `author` branch, and changes the fragment cache line `{% wagtailcache 500 posts tag %}` to include `author` in its key, because without that an author listing could be served from a cached tag listing. A `get_authors` property on `BlogPage`, mirroring `get_tags`, attaches `url` to each person as `{index url}authors/{slug}/`, and `blog_page.html` and `blog-listing-card.html` wrap the names in links to it. People pages under the `people` app, `PersonPage` and `PeopleIndexPage`, are a separate page type and are left alone.

Tests go in a new `bakerydemo/blog/tests/test_author_archive.py`, following the `WagtailPageTestCase` and `setUpTestData` pattern of `base/tests/test_home_page.py`: it builds a `BlogIndexPage` under the root with two `BlogPage` children and two live people, asserts that `authors/<slug>/` returns `200` and lists only that person's posts, that an unknown slug redirects to the index, that a person who is not live is treated as unknown, and that the author names on a blog page are links. Before pushing, the agent runs what `ci.yml` runs: `make lint-server` for `ruff format --check`, `ruff check`, `curlylint` and `djhtml --check`, then `./manage.py check`, `./manage.py makemigrations --check --noinput` with `DJANGO_SETTINGS_MODULE=bakerydemo.settings.test`, and `./manage.py test`, and pastes the results into the pull request.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add author archive pages to this Wagtail blog and open a pull request. Read bakerydemo/blog/models.py, bakerydemo/base/models.py, bakerydemo/templates/blog/blog_index_page.html, bakerydemo/templates/blog/blog_page.html, bakerydemo/templates/includes/card/blog-listing-card.html, bakerydemo/base/tests/test_home_page.py, Makefile and .github/workflows/ci.yml first. Add a unique slug to the Person snippet, filled from first and last name in save() when blank, with migrations in bakerydemo/base/migrations that add the field, fill existing rows appending the primary key on a clash, and make it unique; add it to Person.panels and api_fields. On BlogIndexPage add a route authors/<slug>/ named author_archive that renders blog/blog_index_page.html with author and posts filtered through get_posts(author=...), redirecting to the index with a message like the tag route when the slug is unknown or the person is not live. Add an author heading in the template and include author in the wagtailcache key. Add a get_authors property on BlogPage that attaches each author's archive url, and link author names in blog_page.html and blog-listing-card.html. Leave the people app untouched. Write bakerydemo/blog/tests/test_author_archive.py with WagtailPageTestCase covering the listing, the unknown slug, a non-live person and the links. Run make lint-server, ./manage.py check, ./manage.py makemigrations --check --noinput and ./manage.py test with DJANGO_SETTINGS_MODULE=bakerydemo.settings.test, and paste the results in the pull request.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request that edits `bakerydemo/base/models.py`, `bakerydemo/blog/models.py`, the three templates, adds two migrations under `bakerydemo/base/migrations` and a new `bakerydemo/blog/tests/test_author_archive.py`. The description lists the new URL pattern, shows the migration plan, and pastes the `make lint-server` and `manage.py test` output.

On a repository with the bakerydemo `CI` workflow, the pull request runs `lint-server`, `lint-client`, `manage.py check`, `makemigrations --check` and the test suite in `test-server`, and the `Docker build` workflow runs the tests again inside the container after `load_initial_data`, which exercises the data migration against the demo people.

A reviewer checks the slug clash rule in the data migration, that `wagtailcache` keys on `author`, that a draft person is not reachable, that the people app is unchanged, and that `blog-listing-card.html` still reads well with linked names. Then they publish the first author archive.

## Run it on every Wagtail site with a blog

An agency that runs several Wagtail sites on the same pattern sends one `POST /o/{org}/sessions` per repository with this prompt and that repository in `resources`. Each run reads its own `blog/models.py`, so a site whose authors are already a page type gets a listing route that filters on that relationship instead of a new slug field, and each run opens its own pull request against its own tests.

Give the API key a `webhook_url` and Rush POSTs `run.completed` when each turn ends, with the `session_url` to read the pull request and the test output from.

## Why run it on Rush?

An author archive touches a model, a data migration, a routable page, three templates and a cache key, and the mistakes hide in the joins: a unique slug migration that fails on two people with the same name, or a cached tag listing served under an author URL. In a Rush sandbox the agent runs the migrations against the demo data, runs the full test suite and the linters the repository's own workflow runs, and keeps every command and its output in the run's record.

The pull request carries its own tests in the style the repository already uses, so the behaviour is checked on every future change, not only on the day it lands. The same request works on any Wagtail blog that relates pages to people.

## Frequently asked questions

### Why add a slug instead of using the person's id in the URL?

A URL like `authors/olivia-ava/` reads and shares better than a number, and Wagtail tags already use slugs under `tags/`. The slug is unique, editable in the snippet panel, and filled automatically for existing people by the data migration.

### What happens when two people have the same name?

The data migration appends the primary key to the second person's slug so the unique constraint holds, and `save()` does the same for a new person whose generated slug is taken. An editor can change either slug afterwards.

### Does this change the People section of the site?

No. `PersonPage` and `PeopleIndexPage` in the `people` app are a separate page type with their own templates and are not touched. The archive lists blog posts by the `Person` snippet that `BlogPage` authors already reference.

### Will the fragment cache serve the wrong list?

Not after this change. The `{% wagtailcache %}` tag in `blog_index_page.html` keyed on `posts` and `tag` only; the pull request adds `author` to the key, and a test requests two author archives in a row to show they differ.

## More Wagtail jobs

- [Add Blog Categories to a Wagtail Site](https://getrush.ai/run/add-blog-categories/wagtail/)
- [Add Test Coverage Reporting to Wagtail CI](https://getrush.ai/run/add-coverage-to-ci/wagtail/)
- [Add CSV Export to a Wagtail Admin](https://getrush.ai/run/add-csv-export/wagtail/)

## The same job on other stacks

- [Add Author Pages to an Astro Blog](https://getrush.ai/run/add-author-pages/astro/)
- [Add Author Pages to a Jekyll Blog](https://getrush.ai/run/add-author-pages/jekyll/)
- [Add Author Pages to a VitePress Blog](https://getrush.ai/run/add-author-pages/vitepress/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
