# Accounting for author name changes

Source: https://docs.arcxp.com/en/products/arc-xp-administration/authors/how-to-display-stories-by-a-given-author.html

Authors can change their names for various reasons. When setting up features and templates in PageBuilder that display author information or stories, you need to plan for these changes. Some fields should update with the new name, while others should stay the same to ensure content searches work before and after a name change.

In the Author API, two key fields help manage this: `_id` and `slug`.

- `_id` never changes.
- `slug` can be updated when an author changes their name.

Because of this, some organizations use `slug` in URLs so the author’s bio page can reflect the new name. However, for searching content in the Content API, using `_id` is more reliable. If a search relies on `slug` and the author updates their name, old stories may no longer appear. But if the search is based on `_id`, it always finds content, no matter the name change.

## Example author name change

Suppose we have an author named Taylor Doe. 

```json
{
  "_id": "taylordoe",
  "firstName": "Taylor",
  "lastName": "Doe",
  "byline": "Taylor Doe",
  "slug": "taylor-doe"
}
```

If Taylor changes their name to Taylor Doe Smith, you can update the relevant fields, including `slug`, in the Authors application. However, `_id` remains the same.

```json
{
  "_id": "taylordoe",
  "firstName": "Taylor",
  "lastName": "Doe Smith",
  "byline": "Taylor Doe Smith",
  "slug": "taylor-doe-smith"
}
```

This ensures that Taylor’s bio page URL can reflect the new name, while queries using `_id` still find all their content before and after the change.

## Querying an author’s stories

If you want to create a static query to feature a specific author’s story (for example, showing Taylor’s columns on the homepage), you could query the Content API using the author’s `_id`.

Following [How To Write Content API Queries: Example Queries](https://docs.arcxp.com/en/products/publishing-platform/how-to-write-content-api-queries--example-queries.html), you can retrieve Taylor’s 10 most recent stories with this query:

```
https://api.[ORG].arcpublishing.com/content/v4/search/published?website=[WEBSITE]&q=type:story+AND+credits.by._id:taylordoe&sort=display_date:desc&size=10
```

Using `_id` ensures the query returns stories both before and after Taylor changes their name.

However, if you query using `slug`, like this:

```
type:story+AND+credits.by.slug:taylor-doe
```

Then, when Taylor updates their name (changing `slug` to `taylor-doe-smith`), the query no longer finds their stories, leaving the feature empty.

## Setting up a resolver and template for author bio pages

If you want Author Bio pages to have human-readable URLs (for example, `www.example.com/authors/jane-doe/` instead of `www.example.com/authors/taylordoe/`), you should use the `slug` field to fetch author data from the Author API.

Follow these steps to set up slug-based URLs:

1. **Enable slug editing** \- In the Authors application, ensure `slug` is an editable field. If it’s missing, request access from [Arc XP Customer Support](http://support.arcpublishing.com/).
2. **Use `slug` in URLs** \- When a reader clicks an author’s byline, generate the bio page URL using `slug`, for example, `/authors/{slug}/`.
NoteYou can customize the `/authors/` prefix, for example, `/people/` or `/staff/`, as long as it matches your resolver setup.
3. **Create a content source in PageBuilder** \- Set up a source to fetch author data by `slug`. See [Authors API](https://dev.arcxp.com/api/content-administration/author-api/).
```
https://api.{ORG}.arcpublishing.com/author/v2/author-service/?slug=taylor-doe-smith  
```
4. **Configure the resolver in PageBuilder** \- The resolver should:

  - capture the `slug` from the incoming URL.
  - Send the `slug` to the Author API content source.
5. **Use an API response for Author Bio** \- The global content of the Author Bio template should pull directly from the Author API response.
6. Query the author’s stories using `_id` \- The story feed should use the author’s `_id` from the global content:
```json
{{content._id}}
```

### Handling author name changes

If Taylor Doe changes their name to Taylor Doe Smith, you can update their `slug` to `taylor-doe-smith`. This change automatically updates all stories with their new author reference.

However, old URLs like `/author/taylor-doe/` may still exist in search results or shared links. To ensure a smooth transition, configure `/authors/taylor-doe/` to redirect to `/authors/taylor-doe-smith/`. See [Configuring URL redirects](https://docs.arcxp.com/en/products/delivery/configuring-url-redirects.html).

This setup ensures author pages stay accessible while keeping URLs readable and updated.
