hugo/content/troubleshooting/accented-characters-in-urls.md
Bjørn Erik Pedersen ba45da9d03 Squashed 'docs/' changes from 44fe0285..32356e4e
32356e4e Fix typo in header of shortcode-templates.md
c8f1a2d2 Correct code example for index template function
bfa6a55d Escape code fencing
ff8b2f99 Fix typos in deployment with wercker tutorial
557c36e8 theme: Merge commit '7fbb4bed25001182bfeb91f79db0f0c1936582ee'
7fbb4bed Squashed 'themes/gohugoioTheme/' changes from 7dd8a302..ca53082d
ce31cee0 Add "See Also" config
158cee1b Make the tags into keywords
61600be6 Add a note to the related section
49edb5a2 Relase 0.27.1
c9bbc001 releaser: Add release notes to /docs for release of 0.27.1
213c6c3b Add bugs poster
8b4590cd Add KeyCDN integration tutorial
2b277859 Add tutorial videos to several docs pages
950fef1f Update roadmap to link to the correct milestones page
496f5bf6 Rename relnotes
d6f9378d Bump Netlify versions to 0.27
087fde7f Update 0.27 release notes
603f94ae docs: Document Related Content
3790f6a3 releaser: Bump versions for release of 0.27
0948868c releaser: Add release notes to /docs for release of 0.27

git-subtree-dir: docs
git-subtree-split: 32356e4eabe357ae914f4d1d59e8ae31ce936723
2017-09-21 19:03:00 +02:00

3.5 KiB

title linktitle description date publishdate lastmod keywords categories menu weight draft slug aliases toc
Accented Characters in URLs Accented Characters in URLs If you're having trouble with special characters in your taxonomies or titles adding odd characters to your URLs. 2017-02-01 2017-02-01 2017-02-01
urls
multilingual
special characters
troubleshooting
docs
parent
troubleshooting
false
/troubleshooting/categories-with-accented-characters/
true

Trouble: Categories with accented characters

One of my categories is named "Le-carré," but the link ends up being generated like this:

categories/le-carr%C3%A9

And not working. Is there an easy fix for this that I'm overlooking?

Solution

Are you a macOS user? If so, you are likely a victim of HFS Plus file system's insistence to store the "é" (U+00E9) character in Normal Form Decomposed (NFD) mode, i.e. as "e" + " ́" (U+0065 U+0301).

le-carr%C3%A9 is actually correct, %C3%A9 being the UTF-8 version of U+00E9 as expected by the web server. The problem is that OS X turns [U+00E9] into [U+0065 U+0301], and thus le-carr%C3%A9 no longer works. Instead, only le-carre%CC%81 ending with e%CC%81 would match that [U+0065 U+0301] at the end.

This is unique to OS X. The rest of the world does not do this, and most certainly not your web server which is most likely running Linux. This is not a Hugo-specific problem either. Other people have been bitten by this when they have accented characters in their HTML files.

Note that this problem is not specific to Latin scripts. Japanese Mac users often run into the same issue; e.g., with decomposing into and ゙. (Read the Japanese Perl users article).

Rsync 3.x to the rescue! From an answer posted on Server Fault:

You can use rsync's --iconv option to convert between UTF-8 NFC & NFD, at least if you're on a Mac. There is a special utf-8-mac character set that stands for UTF-8 NFD. So to copy files from your Mac to your web server, you'd need to run something like:

rsync -a --iconv=utf-8-mac,utf-8 localdir/ mywebserver:remotedir/

This will convert all the local filenames from UTF-8 NFD to UTF-8 NFC on the remote server. The files' contents won't be affected. - Server Fault

Please make sure you have the latest version of rsync 3.x installed. The rsync that ships with OS X is outdated. Even the version that comes packaged with 10.10 (Yosemite) is version 2.6.9 protocol version 29. The --iconv flag is new in rsync 3.x.

Discussion Forum References