diff --git a/plugins/category_generator.rb b/plugins/category_generator.rb
index 60ebd4e..d8d9b77 100644
--- a/plugins/category_generator.rb
+++ b/plugins/category_generator.rb
@@ -150,11 +150,9 @@ module Jekyll
def category_links(categories)
dir = @context.registers[:site].config['category_dir']
categories = categories.sort!.map do |item|
- if dir.nil? or dir.empty?
- "#{item}"
- else
- "#{item}"
- end
+ url = item.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase
+ url = "#{dir}/#{url}" unless dir.nil? or dir.empty?
+ "#{item}"
end
case categories.length