# Configuring URL Formats

Source: https://docs.arcxp.com/en/products/publishing-platform/configuring-url-formats.html

You may create multiple URL formats. The formats are tested to see if they match the Arc XP Native Specification (ANS) document based on the criteria. The order they are tested is based on the priority. The matching format will be used to generate the canonical URL.

## Priority

Each format criteria will be tested against the ANS document in order based on the priority. 1 is the highest priority.

## Criteria

The criteria is a JSON document. A match occurs when the ANS document provided has fields that match the criteria.

Here is an example criteria that matches an ANS document.

### Criteria

```json
{
  "type": "story"
}
```

### ANS document

```json
{
    "_id": "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
    "version": "0.7.1",
    "type": "story",
    "display_date": "2018-01-01T12:01:01.0Z",
    "publish_date": "2018-01-01T14:49:00.10Z",
    "headlines": {
        "basic": "The default headline for this story",
        "twitter": "Twitter headline!"
    },
    "websites": {
        "washpost": {
            "website_section": {
                "_id": "/books",
                "_website": "washpost",
                "type": "section",
                "version": "0.6.0",
                "name": "Books",
                "path": "/books",
                "parent_id": "/",
                "parent": {
                    "default": "/"
                }
            }
      }
  }
}
```

## Format settings

You can apply the formats in sequence. For example, `%websites.washpost.website_section._id|trimPath({"count":1})|slugify({"maxLength":20})%`

| **Tag**                                                                                     | **Description**                                                                                                                                                                                                                                                                                                                                                                        |
| ------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| %publish\_date\|year()%                                                                     | The year of the post, four digits, for example, 2004                                                                                                                                                                                                                                                                                                                                   |
| %publish\_date\|month({"padding":true})%                                                    | Month of the year, for example 05\. You can pass{"padding":false}to remove the padding0. The default (with no argument) is to add padding.                                                                                                                                                                                                                                             |
| %publish\_date\|day({"padding":true})%                                                      | Day of the month, for example 28\. You can pass{"padding":false}to remove the padding0. The default (with no argument) is to add padding.                                                                                                                                                                                                                                              |
| %publish\_date\|hour({"padding":true})%                                                     | Hour of the day, for example, 15\. This tag respects the hour format set for the organization. If the format is set to 24, then hours are01, 02, 03, .., 15, 16, ...If the format is set to 12, then hours are1, 2, 3, 4, .., 10, 11, 12. You can pass{"padding":false}to remove the padding0. The default (with no argument) is to add padding.                                       |
| %publish\_date\|ampm()%                                                                     | Morning or afternoon. If your organization uses the 24-hour format, then this is empty. Otherwise, it returns eitheramorpm.                                                                                                                                                                                                                                                            |
| %publish\_date\|minute({"padding":true})%                                                   | Minute of the hour, for example, 43\. You can pass{"padding":false}to remove the padding0. The default (with no argument) is to add padding.                                                                                                                                                                                                                                           |
| %publish\_date\|second({"padding":true})%                                                   | Second of the minute, for example, 33\. You can pass{"padding":false}to remove the padding0. The default (with no argument) is to add padding.                                                                                                                                                                                                                                         |
| %headlines.default\|slugify({"maxLength":100, "language":"de"})%                            | Slugify the headline.maxLengthandlanguageare both optional. The slug never exceeds themaxLengthvalue, but it does cut at the word boundary before it. You can setlanguageto onlydeto correctly convert German characters with diacritics. For example,a-umlautwould be converted toaeinstead ofawhen thelanguageparameter isde. No other values for thelanguageparameter are accepted. |
| %headlines.basic\|removeWords({"allowNumbers": true})%                                      | Removes filler words from headline. Words that are removed: a, at, as, the, in, from, for, of, on, to, and, but. Also removes all characters except - (hyphen), ’ (apostrophe), \\s (whitespace characters), and letters. For example,_Foo, bar, and baz!becomesFoo bar baz_.allowNumbersis optional, defaulting tofalse.                                                              |
| %headlines.basic\|removeEndings({"allowNumbers": true})%                                    | Removes ends of common contractions from headline, excluding\*‘t\*. Ending contractions that are removed: ‘ll, ‘s, ‘ve, and ‘re. Also removes all characters except - (hyphen), ’ (apostrophe), \\s (whitespace characters), and letters. For example,_I’ll_becomes_I_,_you’re_becomes_you_, and_we’re_becomes_we_.allowNumbersis optional, defaulting tofalse.                        |
| %websites.washpost.website\_section.\_id\|trimForwardSlash()%                               | Remove the forward slash.                                                                                                                                                                                                                                                                                                                                                              |
| %websites.washpost.website\_section.\_id\|trimPath()%                                       | Remove all path prefixes. For example,_“/foo/bar/baz”becomes”baz”_.                                                                                                                                                                                                                                                                                                                    |
| %websites.washpost.website\_section.\_id\|trimPath({"count":1})%                            | Remove the first path prefix. For example,_“/foo/bar/baz”becomes”bar/baz”_.                                                                                                                                                                                                                                                                                                            |
| %websites.washpost.website\_section.\_id\|trimPath({"count":2,"reverse":true})%             | Remove two trailing items from a path. For example,_“/foo/bar/baz”becomes”foo”_.                                                                                                                                                                                                                                                                                                       |
| %headlines.basic\|unless({"check":"headlines.meta\_title","then":"headlines.meta\_title"})% | Substitute a field value with a different field value if another field value exists in the document. For example,Output {field} unless {check\_field} in which case {then\_field}.                                                                                                                                                                                                     |
| %\*.\*\*%                                                                                   | Any element within the ANS document. For example:• story.id• story.author• story.headline                                                                                                                                                                                                                                                                                              |
