Jekyll plugin works locally but not on Travis CI - jekyll

I've set up my site to build with Travis CI, and added a few plugins.
This is my Gemfile:
source "https://rubygems.org"
group :jekyll_plugins do
gem "github-pages"
gem "octopress-minify-html" # This one does not work on Travis
gem "jekyll-git_metadata"
gem "jekyll-paginate-v2"
gem "jekyll-tagging"
end
And this is my .travis.yml (with irrelevant information stripped)
language: ruby
cache: bundler
sudo: false
#install: use default `bundle install`
script: bundle exec jekyll build
after_success: .travis/deploy.sh
I tried building my site locally:
$ bundle update
$ bundle install
$ bundle exec jekyll build
And I can see the generated HTML files are minified.
But when I check pushed files from Travis CI, the HTML files are not minified. Also judging from build time, the plugin octopress-minify-html is not working (when it's working the build time is significantly longer).
I tried deleting my whole working directory and re-cloning from GitHub and this plugin is still working locally. I deleted Travis CI cache and let Bundler build everything again, but the plugin still doesn't work on Travis.
What went wrong on Travis?

You can force minification with octopress-minify-html by setting minify_html: true in your config file.

Related

Deploying jekyll app on Cloudcannon fails

I am trying to deploy my jekyll app on the Cloudcannon CMS platform for Jekyll, but my build fails with this output:
Syncing raw files... done
Checking existing local bundle state... failed
Loading gem cache...
Checking gem cache (bundle_cache/Jw8rkIm9v3Cmawv2raEpkN96fz3R5X1Q_XMn7xpGB1s.zip)... no cache
$ export JEKYLL_ENV="production"
$ ruby -v
ruby 2.3.8p459 (2018-10-18 revision 65136) [x86_64-linux]
$ bundle version
Bundler version 2.0.1 (2019-01-04 commit d7ad2192f)
$ bundle config --global jobs 4
Configured concurrent installs!
$ bundle install
Using local cacheable path...
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
jekyll-feed-0.12.0 requires ruby version >= 2.4.0, which is incompatible with
the current version, ruby 2.3.8p459
What am I doing wrong and how can I update the ruby version correctly?
My Gemfile looks like this:
source "https://rubygems.org"
# Hello! This is where you manage which Jekyll version is used to run.
# When you want to use a different version, change it below, save the
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
#
# bundle exec jekyll serve
#
# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
gem "jekyll", "~> 3.8.5"
# This is the default theme for new Jekyll sites. You may change this to anything you like.
gem "minima", "~> 2.0"
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
# gem "github-pages", group: :jekyll_plugins
# If you have any plugins, put them here!
group :jekyll_plugins do
gem "jekyll-feed", "~> 2.4.0"
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
# Performance-booster for watching directories on Windows
gem "wdm", "~> 0.1.0" if Gem.win_platform?
I tried to change the jekyll-feed version and bundle it again but it gave me the same results and I don't want to remove that plugin because I need it.
The issue could be from your Gemfile.lock.
The latest version of jekyll-feed is 0.12.1
Correct your Gemfile to point to any version of jekyll-feed greater than or equal to 0.12.0:
gem "jekyll-feed", "~> 0.12"
The run bundle update so that the new version is installed and included in your Gemfile.lock
Then commit and push your updated Gemfile and the Gemfile.lock into your remote repository.
Jordan from CloudCannon here.
ashmaroli is correct, you're referencing an invalid version number for jekyll-feed. Following ashmaroli's steps should resolve the problem.
As a side note, we'll be adding support for multiple Ruby versions within the next month or two. This will resolve any future incompatibilities with plugins that require a later version of Ruby.
If you have any more questions feel free to contact us, we're more than happy to help :)

what exactly is build the site (jekyll)?

this's a super noob question but, what exactly is "build the site" running this command:
`~/myblog $ bundle exec jekyll serve`
is this to start the server?, because I'm currently using $ jekyll serve :s
As mentioned in its Quick-start guide, this command will build the site on the preview server.
Update:
There is a difference between jekyll serve and bundle exec jekyll serve:
The Gemfile and Gemfile.lock files inform Bundler about the gem requirements in your site. If your site doesn’t have these Gemfiles, you can omit bundle exec and just run jekyll serve.
When you run bundle exec jekyll serve, Bundler uses the gems and versions as specified in Gemfile.lock to ensure your Jekyll site builds with no compatibility or dependency conflicts.
Update 2:
In simple words, "build the site" means the Bundler will use the gems and versions specified in Gemfile.lock to ensure your Jekyll site builds with no compatibility or dependency conflicts and then will run your site on the preview or local server.
The serve command is actually an extension of the build command.
i.e., when a Jekyll user runs jekyll serve or bundle exec jekyll serve, Jekyll first runs the jekyll build command internally and then starts the local server to host the generated site.
So what exactly is this build the site? Well, Jekyll being a static-site generator generates your site using the build command.
Therefore, whether you run jekyll build or jekyll serve, a default jekyll site gets built or generated into the ./_site folder. The minor difference with running the serve command being Jekyll will proceed to start a local web-server and mount the built / generated site onto the server so that you can navigate the site via http://localhost:4000

How do I install one of Github Pages' Jekyll themes for local preview?

I'm trying to install Github Pages' Slate theme on my CentOS 7 VM so I can locally preview my new site using the bundle exec jekyll serve command.
I followed the instructions as best as I could.
I changed the theme minima to jekyll-theme-slate in my _config.yml file.
Then I changed gem "minima", "~> 2.0" to gem "github-pages", group: :jekyll_plugins in my Gemfile file.
After that (since these are their only instructions), I ran bundle exec jekyll serve and it told me I had gems that weren't installed (duh), and suggested running bundle install.
I ran bundle install, which told me there was a conflict in version types of the dependencies and it suggested that bundle update could potentially resolve that issue.
No problem, I ran bundle update. A few plugins/features actually reverted versions here, but I got the Slate theme installed on my machine now, version 0.0.4 for whatever reason.
After that, I ran bundle exec jekyll serve again. I got this error:
Configuration file: /home/peri/my-site/_config.yml
Configuration file: /home/peri/my-site/_config.yml
jekyll 3.4.3 | Error: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
In a way, that error makes sense. For a custom theme to work, I probably need a tool to run their custom scripts. But first, I noticed this extra section in the theme's installation instructions, which directly mentions being able to locally preview the site with that theme.
I downloaded the source, instead of cloning it...I don't need the .git stuff do I?
I edited the script/bootstrap file because /usr/local requires root and using sudo doesn't know about any binary called gem or bundle. I changed gem and bundle to their respective absolute paths and ran sudo ./script/bootstrap inside of slate-master.
Point of the story is, it didn't work for my home/peri/my-site directory when I ran bundle exec jekyll serve. Presumably, it's because they intended for the user's site to be integrated into their theme's source code? That doesn't seem intuitive or correct. So, I investigated ExecJS.
I installed it. gem install execjs
I added gem "execjs", "2.7.0" to my Gemfile file.
Got the same error as before.
How am I supposed to install this Jekyll theme?
Follow these steps after changing the theme in _config.yml:
Gemfile should have only this content:
source "https://rubygems.org"
gem "github-pages"
remove bundler current config: rm -r .bundle/
remove Gemfile.lock: rm Gemfile.lock
Install local dependencies in an isolated folder just for this website: bundle install --path=vendor/bundle
You won't have post and page and home themes, you will need to use just default in all your posts.
Generate and run server: bundle exec jekyll s

Jekyll 3.0 run on localhost:4000 error

Recently, I upgrade my jekyll server from 2.5 to 3.0 , However, it occur a problem:
i render my page on gitpage that is very successful, but when i render it on my local jekyll server, there has a error
my every post's route is /category/YYYY/MM/DD/postName.html (The category is chinese)
At the git page it was no problem
but when i use the localhost server , when i cilck these post anchors , It show no find this html file , and redirect to the 404.html
On local anchors's href such as http://localhost:4000/%E6%8A%80%E6%9C%AF/2016/04/04/array-function.html
and on the git page the href is http://numerhero.github.io/%E6%8A%80%E6%9C%AF/2016/04/04/array-function.html
it was my gitpage address , no any problem : http://numerhero.github.io
Try this:
Install Bundler gem install bundler
Navigate to your project's root cd path/to/project
Run bundle init (will create a Gemfile)
Edit your Gemfile:
source 'https://rubygems.org'
gem 'github-pages'
Run bundle install
Run bundle update (once and awhile)
Serve Jekyll with Bundler: bundle exec jekyll serve
Done!
Your problem must be related to your local dependencies, which must be different than GitHub Pages'. With Bundler, a dependency manager, you will make sure you have github-pages and all it's dependencies installed locally.
Run bundle update once and awhile to make sure you have the last versions installed.
Read more about upgrading Jekyll 2 to 3 here:
http://blog.virtuacreative.com.br/upgrade-jekyll-2-to-3-gh-pages.html

Jekyll serve -w Issue

I am using the jekyll with git-hub-pages on Win7, however no matter what I do the
jekyll serve --watch or
jekyll serve -w
won't start the server (the jekyll serve is working fine).
the produced error has something to do with
custom_require.rb:36 - cannot load such a file --wdm
How can I fix it?
As shown in the error message, wdm is not found.
First, update your gems
gem update
Then, manually install wdm
gem install wdm