2017-10-30 13 views
0

私がsite.categories.firstにアクセスすると、私のすべてのブログ投稿のすべての内容が単一の文字列にまとめられているように見えます。Jekyll site.categories間違った値

site.categories[1]にアクセスすると、空の文字列が表示されます。 site.categoriesの長さは、私が持っているカテゴリの数とほぼ同じです。

私はsite.categoriesのマニュアル編集を確認しましたが、これを行うものは何も表示されません。

答えて

2

inspectフィルタを使用すると、カテゴリの仕組みを理解できます。

{{ site.categories.first[0] }}はカテゴリ名で、 {{ site.categories.first[1] }}は最初のカテゴリの文書を含む配列である
["jekyll", [#<Jekyll::Document _posts/2017-10-31-welcome-to-jekyll.markdown collection=posts>]] 

{ 
"jekyll"=>[#<Jekyll::Document _posts/2017-10-31-welcome-to-jekyll.markdown collection=posts>], 
"update"=>[#<Jekyll::Document _posts/2017-10-31-welcome-to-jekyll.markdown collection=posts>] 
} 

そして{{ site.categories.first | inspect }}のような配列を返します。

{{ site.categories | inspect }}のようなハッシュを返します。

あなたは彼の名前{{ site.categories.jekyll | inspect }}からカテゴリを呼び出すことではなく、することによりすることができますが、それはジキルによってfreezedあるので、あなたはsite.categoriesを変更することはできませんインデックス{{ site.categories[0] | inspect }} => []

です。

+0

多くの試行錯誤を経て私が間違っていたことを理解しました。これは私が今朝投稿する予定のものよりも良い答えです! – Breedly

関連する問題