Slug in page URL

XWiki allows using almost every special character in the page name, and this is very nice!

But the page name also forms the page URL and in the case special characters are used, the page URL become URL-encoded.

For example, the URL of the page named Page with space becomes https://my.wiki.url/Page%20with%20space which is not really readable.

Is it possible to use a slug feature to have a URL like https://my.wiki.url/Page-with-space?

Thanks!

Hi, yes it’s possible. Introduced in XWiki 12.0RC1, see https://www.xwiki.org/xwiki/bin/view/ReleaseNotes/Data/XWiki/12.0RC1/Change003/

See https://extensions.xwiki.org/xwiki/bin/view/Extension/Name%20Strategies%20Module/ for the reference documentation.

I must tell you that I’ve already found that documentation and I’ve already seen the Name Strategies Module.

I’m using XWiki 12.2 but I don’t have the Slug Name Strategy option: I only see Preformatted Names and Character replacement (which is enabled).

I tried to add a new character:

  • Forbidden character: [space]
  • Replacement character: -

But it does not seem to work, because existing pages with a space in their title did not change their URL. Does this work also on already existing pages?

Thanks!

Let’s ask the developer of it since I also tried and couldn’t find it either!

@surli How do we use https://extensions.xwiki.org/xwiki/bin/view/Extension/Name%20Strategies%20Module/#HSlugNameStrategy ?

Thanks

Sorry for that, the name of strategies have changed just after their introduction and I forgot to update the documentation: the Slug Name Strategy is actually named “Preformatted Names” now. It’s the same thing.

This feature only allows to perform checks and transformations on the page name when saving them after the strategy has been enabled. There’s is currently no option to automatically rename all the existing documents to comply with the defined strategy.