# Jekyll plugin gem

**URL:** <https://talk.jekyllrb.com/t/jekyll-plugin-gem/1953>\
**Category:** Help\
**Created:** [July 9, 2018, 2:31pm UTC](https://talk.jekyllrb.com/t/jekyll-plugin-gem/1953 "2018-07-09T14:31:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jabowa](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/jabowa/32/1091_2.png) [@jabowa](https://talk.jekyllrb.com/u/jabowa)\
**Post date:** [July 9, 2018, 2:31pm UTC](https://talk.jekyllrb.com/t/jekyll-plugin-gem/1953/1 "2018-07-09T14:31:19Z")

</div>

Hello, have a quick question. I am attempting to export a Jekyll plugin as a gem (it works fine when in the \_plugins directory within the project).

However, after bulding and pushing the gem to [rubygems.org](http://rubygems.org) and including the gem in the other Jekyll project. The following error is outputted:

`Dependency Error: Yikes! It looks like you don't have jekyll-categorize-pages or one of its dependencies installed. In order to use Jekyll as currently configured, you'll need to install this gem. The full error message from Ruby is: 'cannot load such file -- jekyll-categorize-pages' If you run into trouble, you can find helpful resources at http://jekyllrb.com/help/!`

How do you debug/resolve this issue? I even mimicked a popular jekyll plugin gem ([https://github.com/envygeeks/jekyll-assets](https://github.com/envygeeks/jekyll-assets)) to make sure I have the proper structure and not missing anything. However, this same error is outputted. Is there a way to scaffold a jekyll plugin similar to theme (jekyll new plugin?) or is there a guide to creating a plugin as a gem and including it in Jekyll projects.

---

<div class="post-metadata">

**Author:** ![mmistakes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mmistakes/32/2169_2.png) [@mmistakes](https://talk.jekyllrb.com/u/mmistakes)\
**Post date:** [July 9, 2018, 4:04pm UTC](https://talk.jekyllrb.com/t/jekyll-plugin-gem/1953/2 "2018-07-09T16:04:35Z")

</div>

Are you using a `Gemfile`? If not I’d suggest doing so and adding it there so it’s marked as a dependency.

```auto
source 'https://rubygems.org'

gem 'jekyll'

group :jekyll_plugins do
  gem 'jekyll-categorize-pages'
end

```

Then prepend Jekyll commands with `bundle exec` e.g. `bundle exec jekyll serve`

---

<div class="post-metadata">

**Author:** ![jabowa](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/jabowa/32/1091_2.png) [@jabowa](https://talk.jekyllrb.com/u/jabowa)\
**Post date:** [July 9, 2018, 6:13pm UTC](https://talk.jekyllrb.com/t/jekyll-plugin-gem/1953/3 "2018-07-09T18:13:11Z")

</div>

Yes using a Gemfile. I also have the plugin gem within the group block just as you mentioned above. I am running the project using `bundle exec jekyll serve` also.

When I include it in the Gemfile and run `bundle exec jekyll serve` it serves the project correctly. However, if I add the `jekyll-categorize-pages` within the plugins list in the `_config.yml`, it outputs that error mentioned above.

---

<div class="post-metadata">

**Author:** ![mmistakes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mmistakes/32/2169_2.png) [@mmistakes](https://talk.jekyllrb.com/u/mmistakes)\
**Post date:** [July 9, 2018, 6:52pm UTC](https://talk.jekyllrb.com/t/jekyll-plugin-gem/1953/4 "2018-07-09T18:52:02Z")

</div>

If you’re adding it to the `plugins:` array in \_config.yml then maybe you have to move it out of the plugin group in the `Gemfile`.

I haven’t built my own plugin so plugin devs can probably let you know. But I believe there’s some logic to “autoload” it when declaring it under `group :jekyll_plugins`. That’s likely where the error is coming from.

---

<div class="post-metadata">

**Author:** ![jamesluberda](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/jamesluberda/32/1057_2.png) [@jamesluberda](https://talk.jekyllrb.com/u/jamesluberda)\
**Post date:** [July 9, 2018, 7:33pm UTC](https://talk.jekyllrb.com/t/jekyll-plugin-gem/1953/5 "2018-07-09T19:33:23Z")

</div>

I went ahead and installed `jekyll-categorize-pages` from [rubygems.org](http://rubygems.org), and came up with the same error regardless of configuration. On looking into it further, there seems to be something wrong with the gem, as best I can tell. When I look in the gems folder it installs to, the folder is empty. When I manually download the gem and unpack it,

```auto
gem fetch jekyll-categorize-pages
gem unpack jekyll-categorize-pages

```

I also get an empty directory.

---

<div class="post-metadata">

**Author:** ![jabowa](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/jabowa/32/1091_2.png) [@jabowa](https://talk.jekyllrb.com/u/jabowa)\
**Post date:** [July 10, 2018, 2:36am UTC](https://talk.jekyllrb.com/t/jekyll-plugin-gem/1953/6 "2018-07-10T02:36:06Z")

</div>

I also was getting an empty directory when installing the gem before. Now, I am getting the lib directory of the gem project when inspecting the gem directory after running `gem install jekyll-categorize-pages`. I am not sure what else is missing, I created a Github repo for the plugin here ([https://github.com/bsubedi26/jekyll-categorize-pages](https://github.com/bsubedi26/jekyll-categorize-pages)) if you can spot any issues. Appreciate the help.

---

<div class="post-metadata">

**Author:** ![jamesluberda](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/jamesluberda/32/1057_2.png) [@jamesluberda](https://talk.jekyllrb.com/u/jamesluberda)\
**Post date:** [July 11, 2018, 2:29pm UTC](https://talk.jekyllrb.com/t/jekyll-plugin-gem/1953/7 "2018-07-11T14:29:51Z")

</div>

Just got a chance to take another look at this. Though there are other options, probably the easiest thing to do is to rename your `lib/generator.rb` file to match the name of the gem, i.e. `lib/jekyll-categorize-pages.rb`.

HTH

---

<div class="post-metadata">

**Author:** ![jabowa](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/jabowa/32/1091_2.png) [@jabowa](https://talk.jekyllrb.com/u/jabowa)\
**Post date:** [July 17, 2018, 7:42pm UTC](https://talk.jekyllrb.com/t/jekyll-plugin-gem/1953/8 "2018-07-17T19:42:51Z")

</div>

Thanks! That fixed the problem. Basically changed the file name from `lib/generator.rb` to `lib/jekyll-categorize-pages.rb`.
