Gemfile, _plugins folder, dependency error

Hello,
In order to test a private plugin, I created a _plugins folder in the root of my project.

  • I copied an existing plugin (jekyll-leaflet) in this folder, that will be my future private plugin;
  • I removed jekyll-leaflet from the Gemfile file;
  • I didn’t change the _config.yml file.

Now I have plugins defined in gemfile file and in _plugins folder.

Is it correct ? because I have a dependency error !

jekyll build JEKYLL_ENV=production

Dependency Error: Yikes! It looks like you don’t have /home/jpc/faune_flore_meyrin/_plugins/lib/jekyll-leaflet.rb or one of its dependencies installed. In order to use Jekyll as currently configured, you’ll need to install this gem. If you’ve run Jekyll with bundle exec, ensure that you have included the /home/jpc/faune_flore_meyrin/_plugins/lib/jekyll-leaflet.rb gem in your Gemfile as well. The full error message from Ruby is: ‘cannot load such file – jekyll-leaflet/leaflet-map’ If you run into trouble, you can find helpful resources at Redirecting…!

Shall I also declare my plugin in Gemfile ?

In my _config.yml:

plugins: - jekyll-feed - jekyll-include-cache - jekyll-paginate - jekyll-sitemap - jekyll-exif-data - html-proofer - jekyll-leaflet - jekyll-email-protect

My _plugins folder:
.
└── lib
├── jekyll-leaflet
│ ├── filters
│ │ └── replace-hrefs.rb
│ ├── leaflet-items
│ │ ├── leaflet-geojson.rb
│ │ └── leaflet-marker.rb
│ ├── leaflet-map.html
│ ├── leaflet-map.js
│ ├── leaflet-map.rb
│ ├── leaflet-providers.js
│ ├── leaflet-providers-license.md
│ └── _parse-liquid.rb
└── jekyll-leaflet.rb

jekyll-leafler.rb content:

require “jekyll-leaflet/leaflet-map”
require “jekyll-leaflet/leaflet-items/leaflet-marker”
require “jekyll-leaflet/leaflet-items/leaflet-geojson”
require “jekyll-leaflet/filters/replace-hrefs”

I guess to have found myself …

  • In jekyll-leaflet.rb, require request a full path for each rb file;
  • In _config.yml, in the plugins list, jekyll-leaflet shall also be referended with a full path

Tell me how to avoid that please !

Use require_relative

See for example here I have a plugin file which loads requests.rb in the same folder

Or you can put your gem in a github repo with a .gemspec file and install by adding this to Gemfile

group :jekyll_plugins do
  gem "jekyll-resize", git: "https://github.com/MichaelCurrin/jekyll-resize"
end

Change to suit your gem.

Then

bundle install
bundle exec jekyll serve

Note that if you include a gem inside the group as I did above, it will be enabled and you don’t have to add it to plugins on config.

See the structure of my gem here

Thank you but, for the time being, I continue with a local plugin.

Could you have a look on another question: