:warning: This UI Extension is deprecated and superseded by https://github.com/pauloamgomes/contentful-better-slugs-app
The Better Slugs is a simple UI extension for Contentful CMS that provides a more enhanced way to deal with slug fields. The existing slug functionality in Contentful is limited to one field (title) and therefore a bit limited for most of cases like:
The extension has the following features:
The UI Extension can be installed manually from the Contentful UI following the below steps:
https://raw.githubusercontent.com/pauloamgomes/contentful-better-slugs/master/extension.json
in the urlhttps://pauloamgomes.github.io/contentful-better-slugs/
[locale]
- Will replace the token with the node locale[field:your-field-name]
- Will replace the token with the value of the field[field:your-reference-field-name:field-name]
- Will replace the token with the value of field that belongs to the reference.Example patterns:
[field:title]
Thats the default pattern, and probably for most of the cases would be enough.
[locale]/[field:category:title]/[field:title]
Assuming your locale is English, you have a reference field named category with title value Computers
and your entry title is Laptop 15"
the slug will be: en/computers/laptop-15
[field:date]/[field:title]
Assuming your locale is English, you have a date field named date with value Friday, April 10th 2020
and your entry title is London Event
the slug will be: 2020-04-10/london-event
If you have non dynamic strings in the path and you want to localize them, that would be possible (until a max of 3) using the translations fields, for example having a pattern like /products/[field:name]
and nl
, fr
and de
locales, you can use products=nl:producten,fr:produits,de:produkte
and products
will be produkte
on the slug field for de
locale.
Other options:
Ability to translate strings from the pattern:
Option to not update the slug automatically if entry is published, hide the reset button and set the case mode (lowercase, maintain case, title case):
After cloning, install the dependencies
yarn install
To bundle the extension
yarn build
To host the extension for development on http://localhost:1234
yarn start
To install the extension:
contentful extension update --force
Tested only with text and date fields, so not sure how it can behave with custom fields, it will depend on the value stored in the field.
The slug generation is based on the speakingurl library - https://github.com/pid/speakingurl
Copyright 2020 pauloamgomes under the MIT license.