daattali / beautiful-jekyll

✨ Build a beautiful and simple website in literally minutes. Demo at https://beautifuljekyll.com
https://beautifuljekyll.com
MIT License
5.4k stars 16.27k forks source link

Plugins Like "jekyll-assets" Couldn't Work #284

Closed FongX777 closed 6 years ago

FongX777 commented 7 years ago

Hello, I really like beautiful-jekyll for its easy-to-use feature and elegant outlook. But I have trapped in the condition for a long time that whenever I want to add a plugin, it almost failed...

Take a famous plugin 'jekyll-assets' for example, First I created a folder named '_assets' and put 'css/', 'js/', 'img/' into it, then changed my _config.yml file like it (the appending part):

assets:
  sources:
    - _assets/css/
    - _assets/js/
    - _assets/images/
    - _assets/img/
  compress:
    css: true 
    js: true 

plugins:
  - jekyll-paginate
  - jekyll-assets

here is my Gemfile

source 'https://rubygems.org'
gem "github-pages", '163', group: :jekyll_plugins
# enable tzinfo-data for local build
# gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
gem 'jekyll-paginate'
gem 'jekyll-assets'
gem "coffee-script" # We want to write our javascripts in CoffeeScript
gem "uglifier"      # And we want our javascripts to be minified with UglifyJS
gem "sass"          # And we want to write our stylesheets using SCSS/SASS

I have run bundle install and even gem install jekyll-assets

however, it works nothing, there is no assets file rendered into _site/assets/,
and when I use liquid tags supported by jekyll-assets like {% css main %}

it would show

Configuration file: /home/fongxuan/tmp/beautiful-jekyll/_config.yml
            Source: /home/fongxuan/tmp/beautiful-jekyll
       Destination: /home/fongxuan/tmp/beautiful-jekyll/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
  Liquid Exception: Liquid syntax error (line 1): Unknown tag 'css' in index.html
jekyll 3.5.2 | Error:  Liquid syntax error (line 1): Unknown tag 'css'

(I put {% css main %} in index.html just for testing)

Not just happened in this case, whenever I installed the other plugins(like jekyll-mermaid) and want to use the customized tags, it also showed the same error message...

is something wrong with my code? I really want more plugins in my blog!

Thank you!

OCram85 commented 7 years ago

Hi @FongX777, I recently ran into a similar problem with plugins. So I hope I can help you with this:

Github allows jekyll pages only with supported plugins on Github-Pages. It's called safemode or Plugin Whitelist. This disables foreign gems/plugins of even project internal plugins in the _plugins folder

You run into this if your use the github-pages gem in your Gemfile. In this case the local and onside build process fails. I discovered it while upgrading github-pages version 105 to 163.

You could avoid this by using the native jekyll gem and list all your used plugins manually. But in this scenario you can't let github build you page automatically. If you still wan't this you need a service like appveyor and automate the build process yourself. You can look at my blog source OCram85.github.io if you need some help.

daattali commented 7 years ago

Thanks for offering your advise Marco

FongX777 commented 7 years ago

Thanks a lot! @OCram85 ! I'll give it a try!

eak24 commented 6 years ago

Hi @FongX777 The way I solve this is by building the site locally, with jekyll build and then committing the output in _site to the master branch. The source code lives in the development branch for now, and when I want to update the master, I have to cd into the _site branch where lives another git repo pointing to the master remote. I push the automated changes to master up to GitHub, and that's how I separate the source from what is generated.

OCram85 commented 6 years ago

This is similar to my approach: I changed the default branch to jekyll where my source is. Appveyor builds the site on every change and pushes the output to the master branch. gh-pages uses thi master.

daattali commented 6 years ago

@FongX777 I assume the suggested solutions worked for you so I'm closing this issue