# Create or edit an article

An article is a post that you create in the editor and then open on its article page.
The article editor is the form for entering or revising its title, description, body, and
tags. Use the blank editor to create an article, or open an article that you own to change
it. Selecting **Publish Article** sends either a create request or an update request,
depending on which editor route you opened.

| If you need to… | Go to |
|---|---|
| Create a new article | [Open the editor](#open-the-editor), then follow [Enter article details and publish](#enter-article-details-and-publish). |
| Change an article you own | [Open the editor](#open-the-editor), then follow [Handle create, edit, and tag variations](#handle-create-edit-and-tag-variations). |
| Read the article after publishing | [Read an article](doc:read-an-article). |
| Use the article's other actions | [Article workspace](doc:article-workspace) and [Article actions reference](doc:article-actions-reference). |

## Before you start

Both editor routes require you to be signed in. For an existing article, the editor loads
the article and the current user, then fills the form only when that user is the article's
author.

**Prerequisites**

| Before you begin | What to have ready |
|---|---|
| Sign-in | An authenticated session. |
| New article | The title, short description, article text, and any tags you want to add. |
| Existing article | An article that you own. |
| Existing article values | The article's saved title, description, body, and tags appear in the editor when the ownership check succeeds. |

The new editor starts its title, description, and body controls with empty strings. The
tag input also starts empty.

## Open the editor

Use the new-article link for a blank form. Use an article's **Edit Article** link when you
want to revise an article you own.

**Steps**

1. Select the link for the work you need.

   | If you need to… | Select |
   |---|---|
   | Create a new article | **New Article** |
   | Revise an article you own | **Edit Article** |

**Result:** The article editor opens with the four article inputs and **Publish Article**.

## Understand the editor

The editor contains three article-content controls, one tag input, a tag list, and
**Publish Article**. The first three controls hold the article itself; the tag input adds
labels that appear with it.

| Area | What you use it for | What you see |
|---|---|---|
| Title | Enter the article title. | **Article Title** |
| Description | Enter the article's short description. | **What's this article about?** |
| Body | Enter the article text in Markdown. | **Write your article (in markdown)** |
| Tags | Add article tags. | **Enter tags** |
| Publication | Submit the new or changed article. | **Publish Article** |

The four inputs have no required marker declared for them. To add a tag, enter it in
**Enter tags** and press Enter. A tag already in the list, or a tag containing only
spaces, is not added. Each tag in the tag list has an icon before its tag text; selecting
that icon removes the tag.

While submission is in progress, the editor's form controls are disabled. This includes
the article inputs, the tag input, and **Publish Article**.

## Enter article details and publish

Enter the article's identifying text first, then its body and tags. Publishing uses the
same control for both routes: the new-article route creates an article, while the edit route
updates the article loaded by that route.

**Prerequisites**

- You are signed in.
- The editor is open.
- For an edit, the loaded article belongs to you.

**Steps**

1. In **Article Title**, enter the title.
2. In **What's this article about?**, enter the short description.
3. In **Write your article (in markdown)**, enter the article text.
4. In **Enter tags**, enter a tag.
5. Press Enter to add the tag to the tag list.
6. Repeat steps 4 and 5 for each tag you want to add.
7. Select **Publish Article**.

   | Editor route | What the control submits |
   |---|---|
   | New-article route | A new article without an article identifier. |
   | Edit route | An update containing the loaded article's route identifier. |

**Result:** After a successful create or update request, the application navigates to the
article route for the submitted article.

## Handle create, edit, and tag variations

The editor chooses between creating and updating from the route. A new-article route has
no article identifier, while an edit route has an article identifier and loads the existing
article before filling the form. The edit form also loads the article's saved tag list when
the ownership check succeeds.

| If you are… | Use this behaviour |
|---|---|
| Creating an article | Start with the new-article route; **Publish Article** calls the create path. |
| Editing your article | Start from **Edit Article**; **Publish Article** calls the update path. |
| Adding a new tag | Enter a nonblank tag that is not already in the list, then press Enter; the input clears. |
| Re-entering an existing tag | The duplicate is ignored. |
| Entering only spaces | The blank tag is ignored. |
| Removing a tag | Select the icon beside that tag. |
| Editing an article you do not own | The application returns you to the home page. |

**Steps**

1. For an existing article, review the saved values in **Article Title**, **What's this
   article about?**, and **Write your article (in markdown)** before you edit them.
2. In **Enter tags**, enter a nonblank tag that is not already listed.
3. Press Enter to add the tag.
4. Select the removal icon beside a listed tag when you want to remove it.

**Result:** The tag list contains each accepted tag once, and removed tags no longer appear
in the list.

## When submission goes wrong

**Prerequisites**

- An error is displayed above the form.

**Steps**

1. Read the displayed error.
2. Correct the related information in **Article Title**, **What's this article about?**,
   **Write your article (in markdown)**, or **Enter tags**.
3. Select **Publish Article** again.
4. When the form becomes available, read the displayed error again if it remains.

**Result:** The form becomes available again after the submission finishes.

## Know what happens next

After a successful create or update, the editor opens the submitted article at its article
route. Continue there to read the article or use its article actions.

**Result:** The submitted article page is open.

Continue with [Read an article](doc:read-an-article), [Article workspace](doc:article-workspace),
or [Article actions reference](doc:article-actions-reference).
