Orchard Core Media Slugify - Prompt Templates
Slugify Media Names
You are an Orchard Core expert. Enable and configure the Media Slugify feature so newly created media folders and files get SEO-friendly, URL-safe names.
Guidelines
- Enable the
OrchardCore.Media.Slugifyfeature. Its dependency isOrchardCore.Media. - The feature registers
SlugifyMediaNameNormalizerServiceas the media name normalizer, so folders and files created after it is enabled are slugified automatically. - Example transformation: file
The team (2020).jpgin folderImages & docsbecomesthe-team-2020.jpgin folderimages-docs, so the URL changes from/media/Images%20&%20docs/The%20team%20(2020).jpgto/media/images-docs/the-team-2020.jpg. - Enabling the feature does NOT rename existing folders and files; only new folders and files are slugified. Re-upload or re-create assets to normalize existing names.
- Because different original names can produce the same slug (for example
The team (2020).jpgandThe Team 2020.jpg), uploading both without renaming one may collide. - Transliteration (converting accented/non-Latin characters to their closest ASCII form) is ON by default and can be toggled with the
Transliterateoption under theOrchardCore_Media_Slugifyconfiguration section. - Configuration is bound per tenant through
IShellConfigurationinMediaSlugifyOptionsConfiguration. - All recipe JSON must be wrapped in the root
{ "steps": [...] }format. - All C# classes must use the
sealedmodifier, except View Models.
Enabling Media Slugify
{
"steps": [
{
"name": "Feature",
"enable": [
"OrchardCore.Media.Slugify"
],
"disable": []
}
]
}
Configuration
{
"OrchardCore": {
"OrchardCore_Media_Slugify": {
"Transliterate": true
}
}
}
Transliterate(defaulttrue): when enabled, characters such asé,ü, or Cyrillic letters are transliterated to their closest ASCII equivalents before slugifying. Set tofalseto strip disallowed characters without transliteration.
How It Works
- The feature supplies an
IMediaNameNormalizerServiceimplementation,SlugifyMediaNameNormalizerService, that the Media module calls whenever a folder or file is created or uploaded. MediaSlugifyOptionsConfigurationreads theOrchardCore_Media_Slugifysection from the tenant shell configuration to populateMediaSlugifyOptions.Transliterate.- Normalization runs at creation time, which is why pre-existing assets are unaffected.
Notes
- Use this feature on public-facing sites where clean, predictable media URLs matter for SEO and sharing.
- Plan a one-time cleanup (re-upload or a scripted rename) if you enable slugify on a site that already has many mixed-case or space-containing asset names.
- Combine with
OrchardCore.Mediacache and CDN configuration for a complete media delivery setup.