Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Per Bolmstedt 84 posts 380 karma points
    Jan 20, 2022 @ 07:46
    Per Bolmstedt
    0

    Modify URL segment generator mechanism aka customize slug algorithm

    Is there a way to change the URL segment generator mechanism, aka customize the slug algorithm, aka provide your own ToAscii for node names?

    We want to turn the URL /räk/smörgås/ into /rak/smorgas/, but the default segment generator turns it into /raek/smoergaas/.

    Not quire sure why, since the traditional decomposition for ä is a◌̈ which would remove the diaeresis/trema/umlaut during ascii conversion. Maybe the decomposition is culture specific.

    We've had a look at the code that does this, but I can't easily see how to customize the behavior.

    Using Umbraco v9.2.

  • Patrick de Mooij 73 posts 623 karma points MVP 3x c-trib
    Jan 20, 2022 @ 08:42
    Patrick de Mooij
    100

    Hi,

    You are able to influence the URL segment generator through the appsettings. You are able to configure what chars should replace other chars. There is some more documentation about it here: https://our.umbraco.com/documentation/Reference/V9-Config/RequestHandlerSettings/

  • Per Bolmstedt 84 posts 380 karma points
    Jan 27, 2022 @ 12:19
    Per Bolmstedt
    0

    Thanks. Just to verify, configuring the Request Handler will change how Umbraco generates URLs as well as how URLs are resolved into documents, i.e. both ways?

  • Patrick de Mooij 73 posts 623 karma points MVP 3x c-trib
    Jan 27, 2022 @ 12:24
    Patrick de Mooij
    0

    Yes, that is correct

  • Per Bolmstedt 84 posts 380 karma points
    Feb 07, 2022 @ 09:42
    Per Bolmstedt
    0

    I can't get this to work. I've configured like so:

    "CMS": {
      "RequestHandler": {
        "AddTrailingSlash": false,
        "ConvertUrlsToAscii": "try",
        "CharCollection": [
          {
            "Char": "å",
            "Replacement": "a"
          },
    

    However, an "å" in a node name is still turned into "aa", both in Admin in the URLs list for an item and on the front-end. The URL with "a" is a 404.

    Schema validation says the configuration is valid. There are no errors or warnings on startup. The AddTrailingSlash setting is applied correctly.

    Is there something else needed for the char replacements to take effect?

    EDIT: Sorry, just noticed this has been broken since 9.0 and will be fixed in 9.3.0 which seems due in a few days.

    EDIT: Working fine in 9.3.

Please Sign in or register to post replies

Write your reply to:

Draft