permalink generation removing special characters and spaces #782

Closed
nalmeida opened this Issue Jan 28, 2013 · 8 comments

Projects

None yet

5 participants

I am using the following configuration:
permalink: /:categories/:title
to generate my posts folder structure but I would like to remove every special characters and also replace all the spaces for "-"

My category name is: "Acentuação"

Now:
http://localhost:4000/Acentua%C3%A7%C3%A3o/testando-acentuacao/

Preferred:
http://localhost:4000/acentuacao/testando-acentuacao/

Is there any way to do it without changing the Jekyll core?
Any plug-in?

Regards
Nicholas

I have found a external lib to do this replacement. https://github.com/wagnerandrade/wind/blob/master/lib/extend_string.rb

I have tested importing it inside the post.rb and passing the slug and the c variables trough the urlize method:

...
"title"      => CGI.escape(slug.urlize),   # removing accents
"i_day"      => date.strftime("%d").to_i.to_s,
"i_month"    => date.strftime("%m").to_i.to_s,
"categories" => categories.map { |c| URI.escape(c.urlize) }.join('/'),   # removing accents
...
Owner
parkr commented Jan 31, 2013

Cool! I'll take a look at this more closely soon.

nalmeida commented Feb 6, 2013

The suggested fix would also add the possibility of having multi-word category names such as:

---
layout: post
title: Bla
categories:
 - My assome category with Acentuação
---
...

Currently, it creates the following site structure

http://localhost:4000/My/assome/category/with/Acentuação/...

Using the urlize it will be:

http://localhost:4000/my-assome-category-with-acentuacao/...
@x3ro x3ro added a commit to x3ro/jekyll that referenced this issue Apr 9, 2013
@x3ro x3ro Refactor URL processing/generation into separate module
This is done to prepare for improved permalink generation
for URLs containing special characters, as proposed in
issue #782
cfcbe1f
Owner
parkr commented Apr 14, 2013

@mojombo Do you think we can push this off until post-1.0 as well? Once 1.0 is out, I'm hoping to release every couple weeks with bug fixes and the like. No need to wait on 1.0 until this is done, in my opinion.

Contributor
mojombo commented Apr 14, 2013

Yeah definitely bump this to a future release. Character manipulation is something that will take some time to work through, and we'll need to be careful about backwards compatibility.

Contributor
x3ro commented Apr 16, 2013

@mojombo @parkr Since the refactored URL generation in #944 does not modify the current behavior so far, it could be merged before actually making any changes to the URL generation, right? This would make the actual modification at a later date easier, and would also allow adding custom URL segments easier than it is currently possible.

Owner
parkr commented Feb 17, 2014

Implementing this in core will break any URLs created with the current system, and maintaining backwards compatibility is more effort than it'd be worth. If anything, we should have a means of "translating" category names, but i18n is a ways off, too.

Closing this out as inviable.

@parkr parkr closed this Feb 17, 2014
@fusilli fusilli referenced this issue in jekyll/jekyll-help May 17, 2015
Closed

category with 2 words url problems #129

I try to add this Lib(https://github.com/wagnerandrade/wind/blob/master/lib/extend_string.rb) to my project but i'ts not working...
Can someone give me some reference to use?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment