photo by Hector Melo A.

Better URLs for Scandinavian letters in N2CMS

In N2CMS the default behavior when creating a page containing ‘Å’ or ‘Ö’ in the URL is to replace it with ‘Ae’ and ‘Oe’. I find this makes less readable URLs, and I believe people are more used to read URLs where you replace it with a single letter, e.g. ‘Å’ to ‘A’.

Example for page title “Räksmörgås”:
Default: raeksmoergas/
Wanted: raksmorgas/

To change this default behavior in N2CMS you need to add this configuration to Web.config:

<n2>
  <edit>
    <nameEditor>
      <replacements>
        <remove name="smallAE"/>
        <remove name="capitalAE"/>
        <remove name="smallOE"/>
        <remove name="capitalOE"/>
        <remove name="theRest"/>
 
        <add name="smallAE-new" pattern="[æä]" value="a" />
        <add name="capitalAE-new" pattern="[ÆÄ]" value="A" />
        <add name="smallOE-new" pattern="[ö]" value="o" />
        <add name="capitalOE-new" pattern="[Ö]" value="O" />
        <add name="theRest-new" pattern="[^. a-zA-Z0-9_-]" value="" />
      </replacements>
    </nameEditor>
  </edit>
</n2>

published in N2CMS