Difference between "github-pages" and "jekyll" gem? - jekyll

What are the main differences between the two gems jekyll and github-pages?
And why does GitHub recommend using github-page with Pages?

The github-pages gem will load all dependencies needed to run Jekyll exactly like on GitHub Pages.
jekyll gem is just Jekyll.

Related

I would like to develop a jekyll gem plugin, but I don't know how to start

I don't find tutorials to develop and publish jekyll plugins or to extend jekyll functionalities.
Here is Jekyll's documentation on how to get started with Jekyll plugins https://jekyllrb.com/docs/plugins/

Jekyll -- gems need two different versions of sitemap?

I'm trying to install a Jekyll theme gem called "alembic-jekyll-theme". I tried to run a bundle update and received the following:
Bundler could not find compatible versions for gem "jekyll-sitemap":
In Gemfile:
alembic-jekyll-theme (~> 3.1) was resolved to 3.1.0, which depends on
jekyll-sitemap (~> 0.13)
github-pages was resolved to 203, which depends on
jekyll-sitemap (= 1.4.0)
What am I supposed to do when a theme and GitHub pages require two different versions? How would I go about updating the version number of "jekyll-sitemap"?
GitHub Pages does not support custom themes directly as gems. If you want to use GitHub Pages with a custom theme that is not directly included in your source code, you'll need to install the theme as a remote theme. In your case, follow the steps in the Alembic theme README to install it as a remote theme.
If you don't intend to use GitHub Pages, then do not install the gh-pages gem, and just install Alembic as a Jekyll theme.

Is the gemfile.lock file needed in a Jekyll site hosted with Github Pages?

Lately I've gotten into Jekyll for building documentation sites and hosting them on Github Pages. I understand Github Pages has a very limited list of what is allowed plugin wise. While doing some vulnerability testing I found out the file Gemfile.lock is vulnerable to XML External Entity (XXE) Injection.
In my research I've read:
Should Gemfile.lock be included in .gitignore?
A Gem's Gemfile.lock should NOT be in source control.
Setting up your GitHub Pages site locally with Jekyll
After reading the accepted answer of:
Assuming you're not writing a rubygem, Gemfile.lock should be in your repository. It's used as a snapshot of all your required gems and their dependencies. This way bundler doesn't have to recalculate all the gem dependencies each time you deploy, etc.
but I have no control over the Jekyll site. Please correct me if I'm understanding the process but Github Pages builds the site and if the Gemfile.lock is for development of Gems and that isn't something I can control it's ok to remove the file and add to the .gitignore?
GitHub Pages doesn't look for a Gemfile.lock file nor the Gemfile itself.
All it needs is a proper config file to load gems / plugins.

Jekyll generator not loaded

I currently experienced an issue with Jekyll generators. Just implemented one regarding AMP. So I placed it inside the _plugins folder, and named it amp_generate.rb.
Tried to add some puts 'foo' but nothing on my terminal...
Giving a look at jekyll serve -V, it seems the generator never appears...
Any idea? Here is the source code : https://github.com/tiste/www
You're running in safe: true mode (like on github pages) because gem 'github-pages', group: :jekyll_plugins instruct jekyll to run in github pages context.
Simply change to gem 'github-pages'.
You can even simplify your Gemfile to be :
source 'https://rubygems.org'
ruby RUBY_VERSION
gem 'github-pages'

Why does my site work using Jekyll 1.4.3 but not Jekyll 2.0.2?

After upgrading my web application based on Jekyll 1.4.3 to Jekyll 2.0.2, my home page does not incorporate the specified layout file.
Here are the steps to reproduce:
Download https://github.com/morea-framework/basic-template/tree/jekyll-2.0.
This is the jekyll-2.0 branch of my web application, which is a stripped down version to illustrate the problem. If you clone the repo, be sure to switch to the jekyll-2.0 branch.
gem uninstall jekyll
gem install jekyll -v '1.4.3'
This installs the version of jekyll in which the site builds correctly. For reasons not apparent to me, I ran into problems when I had both 1.4.3 and 2.0.2 installed simultaneously.
cd basic-template/master/src
jekyll serve --baseurl ''
This brings up my web application. If you now go to http://localhost:4000, you should see:
Now control-c to stop the application, and invoke:
gem uninstall jekyll
gem install jekyll
jekyll serve --baseurl ''
These three commands uninstalls Jekyll 1.4.3, installs Jekyll 2.0.2, and reruns Jekyll. Now if you refresh http://localhost:4000, you should see:
As you can see, the CSS styling is no longer present. That's because the layout specified in the Front Matter has for some reason not been included.
Can anyone tell me why my code no longer works correctly under Jekyll 2.0.2?
Your post references the post.html layout in it's front matter, which in turn references the default layout. The default layout doesn't exist in your _layouts folder:
https://github.com/morea-framework/basic-template/blob/jekyll-2.0/src/_layouts/post.html
You should always have a default layout.