Skip to main content

Configuring URL Formats

You may create multiple URL formats. The formats are tested to see if they match the 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

{
  "type": "story"
}

ANS document

{
    "_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 padding 0. 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 padding 0. 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 are 01, 02, 03, .., 15, 16, ... If the format is set to 12, then hours are 1, 2, 3, 4, .., 10, 11, 12. You can pass {"padding":false} to remove the padding 0. 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 either am or pm.

%publish_date|minute({"padding":true})%

Minute of the hour, for example, 43. You can pass {"padding":false} to remove the padding 0. 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 padding 0. The default (with no argument) is to add padding.

%headlines.default|slugify({"maxLength":100, "language":"de"})%

Slugify the headline. maxLength and language are both optional. The slug never exceeds the maxLength value, but it does cut at the word boundary before it. You can set language to only de to correctly convert German characters with diacritics. For example, a-umlaut would be converted to ae instead of a when the language parameter is de. No other values for the language parameter 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! becomes Foo bar baz. allowNumbers is optional, defaulting to false.

%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 Iyou're becomes you, and we're becomes we. allowNumbers is optional, defaulting to false.

%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