Forum

Thread tagged as: Suggestions, Blog

Using Chinese characters in the blog url

We host a second copy of perch that is entirely localized for China/Hong Kong. I was wondering if there was a way for the blog posts to use the Characters, or there Unicode equivilant, instead of the default conversion to a random string. While I'm not very learned on translation over the web, I feel like there is be an SEO benefit for our Chinese market.

Locky Keaney

Locky Keaney 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Do you have the PHP Internationalization extension installed on your server?

Sorry for no reply, I've been on holiday.

I am enabling it now. Is the next step a rewrite for any of the blog url's? Or can it be done directly from perch?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Rewrite in what sense?

Using the .htaccess file to enable to use of Chinese characters and rewrite the URL.

what we are looking for is the URL to look like this"

example.com.hk/blog/於本網站核
Drew McLellan

Drew McLellan 2638 points
Perch Support

Sure, you'd need to do that in your server config. Perch doesn't have URL rewriting - you need Perch Runway for that.

Ok, So I've done all the internationalization settings I can on the server. When I go to change the URL of the blog post to Chinese it comes out with the english characters, like this: example.com.hk/blog/guo-tai-ji-gang-long-jian-xi-ji-shi-pei-xun-ji-hua

Will we need to upgrade to runway to get the desired outcome?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is that the correct transliteration of the input?

Yeah, so the title of the post is 國泰及港龍見習機師培訓計劃 and I put that into the URL input and save the blog post, and it gets changed to guo-tai-ji-gang-long-jian-xi-ji-shi-pei-xun-ji-hua when I hit save.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Right, that's the designed behaviour. If you don't want that behaviour, use a text field rather than a slug field.

I created another text input in the template file <perch:blog label="Chinese URL" id="chineseUrl" type="text" supress="true" /> and then changed the settings to /blog/{chineseUrl} but it either comes up with a 404 message, or goes straight to the blog index. Using the arabic character URL still takes the user to the blog post. I've checked the server and it can server international domains fine.

I'm a bit unsure about how the slug system is supposed to work. Should slug format be {postTitle}? Or something relating to the Chinese Url?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you then filtering the posts by your new field?

perch_blog_custom([
    'filter' => 'chineseUrl',
    'match' => perch_get('whatever-it-is-in-the-route'),
]);