29

Following the jekyll documentation found here: https://jekyllrb.com/docs/themes/ I was trying to install and change a gem based theme so I have chosen the jekyll-theme-primer for this and I've run the following command and instructed under the https://jekyllrb.com/docs/themes/#installing-a-theme section:

gem "jekyll-theme-primer"

and got this error:

ERROR:  While executing gem ... (Gem::CommandLineError)
    Unknown command jekyll-theme-awesome

After doing some research I've found that I should have added install to my query as described here: While executing gem, unknown command

After running this:

gem install "jekyll-theme-primer"

I successfully installed the primer gem based theme and got the following confirmation:

Successfully installed jekyll-theme-primer-0.5.2
Parsing documentation for jekyll-theme-primer-0.5.2
Done installing documentation for jekyll-theme-primer after 0 seconds
1 gem installed

First question: Was the official documentation incorrect or am I missing something?

I proceeded to run the bundle install command:

bundle install

and replaced my current minima theme from the _config.yml with the jekyll-theme-primer by adding/replacing this line:

theme: jekyll-theme-primer

Now when I tried to run either the:

jekyll serve

or the:

bundle exec jekyll serve

commands, I get the following error:

jekyll 3.5.2 | Error:  The jekyll-theme-primer theme could not be found.

So why it can't find the gem theme if the installation was successful?

Isaz
  • 395
  • 1
  • 3
  • 5
  • To make sure you have the name correct, go to the top of your gemfile and look for which gem host is being used like `source "https://rubygems.org"`. Then you can search rubygems.org for [jekyll-theme-primer](https://rubygems.org/search?utf8=%E2%9C%93&query=jekyll-theme-primer) and get usage info there – KyleMit Jul 16 '20 at 01:11

1 Answers1

33

From what I gather, it looks like you did not add jekyll-theme-primer to your Gemfile, but instead simply executed gem "jekyll-theme-primer" in the terminal and later installed the gem correctly after encountering the Gem::CommandLineError

So, in short, simply follow the steps below:

  • Add the theme-gem to your Gemfile
  • add the theme to your _config.yml (correctly done already..)
  • Run: bundle install (just to make sure Bundler is able to use it)
  • Run: bundle exec jekyll serve

Adding a theme-gem to a Gemfile:

Open your current Gemfile in a text-editor, and replace entire line gem "minima", "~> 2.0" with your theme gem. i.e. gem "jekyll-theme-primer", "~> 0.4"

ashmaroli
  • 5,209
  • 2
  • 14
  • 25
  • I guess this is where I need help. How do I add the theme-gem to my gemfile? I've followed the instructions for "Add the theme to your site’s Gemfile:" and executed this `gem "jekyll-theme-primer"` but like I said earlier I got this error: `ERROR: While executing gem ... (Gem::CommandLineError) Unknown command jekyll-theme-awesome` – Isaz Sep 27 '17 at 00:57
  • Thank you for the clarification! What does the `~> 0.4` stand for and where do I get it? – Isaz Sep 27 '17 at 23:37
  • The `~> 0.4` stands for the gem version and you can get it from the theme's site or GitHub repo – Newton Karanu Feb 10 '20 at 18:53