jekyll plugin not work on github

穿精又带淫゛_ 提交于 2020-01-21 11:24:07

问题


I want to change the order of pages in navitation bar by using jekyll-plugins / weighted_pages.rb from here.

This plugin work very well on my localhost but github.
I find the navitation bar is empty on github host, which seems this plugin does not work.
How can I solve this problem?

I copy weighted_pages.rb code below:

# 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

Add weight attribute to the front matter of your pages (like weight: 1) and use site.weighted_pages instead of site.pages in your loops.


回答1:


Github pages does not support plugins. From jekyll's documentation:

GitHub Pages is powered by Jekyll, however all Pages sites are generated using the --safe option to disable custom plugins for security reasons. Unfortunately, this means your plugins won’t work if you’re deploying to GitHub Pages.

The same documentation page also gives you a workaround:

You can still use GitHub Pages to publish your site, but you’ll need to convert the site locally and push the generated static files to your GitHub repository instead of the Jekyll source files.



来源:https://stackoverflow.com/questions/20369397/jekyll-plugin-not-work-on-github

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!