All About the URL Field in the Contentstack SaaS Headless CMS

This blog post contains all the information that I have been able to gather about the URL field in the Contentstack SaaS headless content management system. If you have questions or additional information about the URL field, please comment on this blog post.

Read the Contentstack documentation for the URL field:

Content delivery solutions for websites driven typically associate individual entries (records) in a content management system with unique URLs. In CMS, URL typically refers to the path component, such as /path/to/page, without the protocol, host, and port used to determine the application to service the request, which the solution adds to URLs at runtime.

Such content delivery solutions must include techniques to determine the URL of entries (records) in the CMS and, conversely, entries associated with URLs. Contentstack provides a URL field type that you can use to associate URLs (technically, URL paths) with entries.

The URL field is a single-line text field with properties to configure logic that Contentstack applies to set the field value in entries based on the current date, title, and ID (under Custom) of the entry.

URL field with Date and Title pattern selected

If you use the title property in the configuration of the URL field, then when you create a new entry, before you save, changing the title field updates the URL field with an equivalent hyphenized (yep, 1850!) lowercase string. In December 2021 I selected Date and Title and created an entry with the title “This *Is* the Title!”. Contentstack set the URL field to the following value, which is not read-only.

/2021/12/08/this-is-the-title-

If you select Custom, then you can enter a value with a special syntax:

Custom syntax for URL field

The URL field is both that field and a field type. The URL field always has the JSON key url.

The URL field can only exist once within a content type. After you add the URL field and save a content type, the URL field type disappears from the field types available in the content type builder.

Before adding the URL field to a content type:

Adding another field after adding the URL field:

Not all content management solutions drive websites and not all websites must use the URL field. Solutions can use techniques other than the URL field type to associate URLs with entries. Content delivery solutions for websites must include some logic for determining content associated with a URL, and the URL field is just one approach.

To map URLs to entries and entries to URLs, some solutions may use a single-line text field other than the URL field (whether using the key url or not), or a custom field, while others may apply logic to determine URLs at generation or runtime. For example, a solution could use a search index or other facility to construct path values based on URL field values (based on the titles of the entries) and hierarchical references between entries.

 Some solutions use different techniques to determine the URLs of different types of entries, for example using the URL field for most types of entries but routing based on content type and entry ID for certain content types.

Even for solutions that use the URL field to associate URLs with entries, some content types do not include the URL field, as not all entries have URLs.

You can add the URL field to any content type, but you cannot add it to a group field, a global field, or within a modular blocks field. In such cases where you might consider using the URL field, you may want to use the link field type, a single-line text field type, or a custom field type.

The documentation includes instructions to configure a stack to require unique values in the URL field across all content types. Contentstack handles the URL fields differently for single content types, which allow the creation of a single entry rather than any number of entries. For example, URL patterns do not apply to the URL field for single content types.

One thought on “All About the URL Field in the Contentstack SaaS Headless CMS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: