{seoname:string:unique_slices:encoding}

Description

Generates a URL-safe SEO name (slug) from a string. It lowercases the text, transliterates accented letters to plain ASCII, replaces every character that is not a letter, digit, dash, underscore or dot with a dash, collapses repeated separators, and trims leading and trailing dashes and dots. The text About Us becomes about-us. A result longer than 124 characters is cut (without splitting a word where possible). Give a second argument to make the slug unique within one or more slices: pass all to cover every related slice, or a dash-separated list of slice IDs. When an active, expired, pending or holding item already uses the slug, a numeric suffix (-2, -3, and so on) is appended until it is unique. The optional third argument is the source character encoding used for transliteration; the default is utf-8.

Parameters

string required

The text to convert into a slug. Letters are lowercased and accents transliterated; spaces and other separators become dashes.

unique_slices optional default (empty - no uniqueness check)

Where the slug must be unique. Leave empty for no uniqueness check. Use all for every related slice, or a dash-separated list of slice IDs. On a collision a numeric suffix (-2, -3, ...) is appended.

encoding optional default utf-8

Source character encoding used to transliterate accented letters to ASCII (for example windows-1250, iso-8859-2, iso-8859-1).

Examples

test{seoname:About Us}
Expectedabout-us
Actualabout-us
The simplest use: a string in, a lowercase dash-separated slug out. The space becomes a dash.
test{seoname:Hello World! Latest News}
Expectedhello-world-latest-news
Actualhello-world-latest-news
Every run of non-alphanumeric characters (spaces, the exclamation mark) collapses to a single dash, and trailing separators are trimmed.
test{seoname:Annual Report 2024}
Expectedannual-report-2024
Actualannual-report-2024
Letters are lowercased; digits are kept as-is.
test{seoname:report.final.v2}
Expectedreport.final.v2
Actualreport.final.v2
Dots survive in the slug (seoname allows them, unlike most other characters), which suits version or file-style names. Repeated dots collapse to one.
test{seoname:C++ Programming Guide}
Expectedc-programming-guide
Actualc-programming-guide
Symbols such as plus signs are treated as separators: each run becomes one dash and trailing dashes are trimmed.
test{seoname:Café Restaurant}
Expectedcafe-restaurant
Actualcafe-restaurant
Accented letters are transliterated to plain ASCII using the source encoding (default utf-8). The input here uses the HTML entity for the accented e, so the stored example stays ASCII-clean; seoname decodes it before slugifying.
test{seoname:{item:ce4ac95c48c3bbe590b80794e47c3e7b:_#SHORTTXT}}
Expectedhello-world
Actualhello-world
The everyday use: feed seoname the value of a field so each item gets a clean slug. Here the source is an item's text field reading Hello World. The same pattern builds anchor ids and href targets from a heading.
virtual{seoname:About Us:9e1d2b9f88e3d6c3bf0eb967378610d6}
Expected(about-us, or about-us-2 if that slug is already taken in the slice)
Actualabout-us
With a second argument, the slug is checked against the given slice (here one slice ID; use a dash-separated list, or all for every related slice). If an item there already uses about-us, a numeric suffix is appended (about-us-2, about-us-3, and so on) until the slug is unique. Virtual because the result depends on the slice contents at render time.