默认情况下,所有页面都编码为“utf-8”。但你可以覆盖它config.yml
:
encoding: ENCODING
但 jekyll 似乎不能很好地工作(直到现在:2017 年 1 月),unicode 没有英文字符,请参阅此类似问题Slugify 字符串似乎不适用于 Unicode/瑞典字母 #4623 https://github.com/jekyll/jekyll/issues/4623。如果你不把类别放在里面,这个空间也会造成一个小问题' '
解决方法是在将“类别”集成到url
, 用一个发电机 https://jekyllrb.com/docs/plugins/#generators, with:
slug = category.strip.downcase.gsub(' ', '-').gsub(/[^\w-]/, '') # categories slugiffier
// use this slug as the category id
上面的 slugifier 只是小写,用 - 替换空格,并删除所有非 ASCII 字母,因此您需要添加其他替换gsub
在最后一个之前.gsub(/[^\w-]/, '')
取代:
é è ê -> e
à â -> a
...
Update
在阅读 GitHub 列表中的旧 jekyll 问题以实施“修复”时,我发现了这个详细解决方案 https://github.com/jekyll/jekyll-help/issues/129#issuecomment-61255284由 @david-jacquel 在 2014 年发布:
这需要改变 Jekyll 生成帖子 URL 的方式。这个可以
用插件来完成。
# _plugins/post.rb
module Jekyll
class Post
# override post method in order to return categories names as slug
# instead of strings
#
# An url for a post with category "category with space" will be in
# slugified form : /category-with-space
# instead of url encoded form : /category%20with%20space
#
# @see utils.slugify
def url_placeholders
{
:year => date.strftime("%Y"),
:month => date.strftime("%m"),
:day => date.strftime("%d"),
:title => slug,
:i_day => date.strftime("%-d"),
:i_month => date.strftime("%-m"),
:categories => (categories || []).map { |c| Utils.slugify(c) }.join('/'),
:short_month => date.strftime("%b"),
:short_year => date.strftime("%y"),
:y_day => date.strftime("%j"),
:output_ext => output_ext
}
end
end
end
——大卫·雅克尔谈Jekyll/jekyll-help/issues/129# https://github.com/jekyll/jekyll-help/issues/129#issuecomment-61255284
这将解决空间问题,并给出解决编码名称的起点