jekyll插件无法在github上运行
我想通过使用jekyll-plugins / weighted_pages.rb
来改变导航栏中页面的顺序。
这个插件在我的localhost上运行得非常好,但是github。
我发现导航栏在github主机上是空的,看起来这个插件不起作用。
我怎么解决这个问题?
我复制下面的weighted_pages.rb
代码:
# Generates a copy of site.pages as site.weighted_pages # with pages sorted by weight attribute. Pages with no # weight specified are placed after the pages with specified weight. module Jekyll class WeightedPagesGenerator < Generator safe true def generate(site) site.config['weighted_pages'] = site.pages.sort_by { |a| a.data['weight'] ? a.data['weight'] : site.pages.length } end end end
将weight
属性添加到pages (like weight: 1)
的前端pages (like weight: 1)
并在循环中使用site.weighted_pages
而不是site.pages
。
Github页面不支持插件。 来自jekyll的文档 :
GitHub Pages由Jekyll提供支持,但所有Pages网站都是使用–safe选项生成的,以便出于安全原因禁用自定义插件。 不幸的是,这意味着如果您要部署到GitHub页面,您的插件将无法运行。
相同的文档页面还为您提供了一种解决方法:
您仍然可以使用GitHub页面来发布您的站点,但您需要在本地转换站点并将生成的静态文件推送到GitHub存储库而不是Jekyll源文件。