【问题标题】:Why Jekyll convert my Capital words into lowercase in Categories为什么 Jekyll 在类别中将我的大写单词转换为小写
【发布时间】:2013-10-05 03:02:14
【问题描述】:
graphics3d
word-cloud
math.se

这是我的categories

为什么都是小写。

我怎样才能把它们变成大写,因为我电脑中的目录是大写的。

![enter image description here][1]

还有我的头衔:WordList,Jekyll 会将其转换为 Wordlist

YML 前沿:

---
layout: post
category: Mathematica//Math-Experiment
Tags: Formula Periodic Sequence
---

https://github.com/HyperGroups/hypergroups.github.com/blob/master/_posts/Mathematica/Math-Experiment/2013-09-11-Math_Experiment_Limit.html

你看,我想 Mathematica 变成类别而不是 mathematica

【问题讨论】:

  • @ColeJohnson 现在怎么样。

标签: github jekyll


【解决方案1】:

以下是我的设置。

ruby 2.1.1p76
jekyll 1.0.2

我也遇到了同样的问题,最终修改了下面的jekyll源文件。 (我用“rvm”)

# vim /usr/local/rvm/gems/ruby-2.1.1/gems/jekyll-1.0.2/lib/jekyll/post.rb

我删除了小写方法。

# diff post.rb.org post.rb
79c79
< self.categories = self.data.pluralized_array('category', 'categories').map {|c| c.to_s.downcase}
---
> self.categories = self.data.pluralized_array('category', 'categories').map {|c| c.to_s}

【讨论】:

    【解决方案2】:

    将其设为小写使 Jekyll 更容易解析和处理项目。

    我有几个问题要问你:

    1. Jekyll 对类别名称的小写是否会损害您的网站性能或给您带来任何麻烦?
    2. 还是仅仅为了美观?

    如果是后者,解决方案是再次将其大写。

    {% for tag in page.categories %}
    <a href="{{ site.url }}/categories/index.html#{{ page.categories | cgi_encode }}" data-toggle="tooltip" title="Other posts from the {{ tag | capitalize }} category" rel="tag">{{ tag | capitalize }}</a>
    {% unless forloop.last %}&nbsp;&bull;&nbsp;
    {% endunless %}
    {% endfor %}
    

    【讨论】:

    • -1。这不是一个好的(甚至是完整的)解决方案,因为它假设只有第一个字母大写,但情况可能并非如此(例如jQuery vs HTTP vs Jekyll)。
    猜你喜欢
    • 1970-01-01
    • 2018-08-06
    • 2019-06-15
    • 2019-12-02
    • 2014-08-11
    • 2018-08-29
    • 2020-02-17
    • 2017-07-28
    • 2018-08-17
    相关资源
    最近更新 更多