How to include a file inside a gem?


#1

I am creating a gem but not able to include a file so that user don’t have to create the same file while using the gem.

I tried it, didn’t work for me.


#2

Think this is a Jekyll limitation. It only “copies” _layouts, _includes, _sass, and assets bundled in the gem-based theme.

@ashmaroli’s jekyll-data plugin can help with _data and .yml config files you may have that you’d like copied over for the user. But other files like .md or .html aren’t supported currently.


#3

@yashumittal How did you come to this conclusion?
Did you build & install the gem locally and then examined the contents of the installed gem…?
Or did you simply run jekyll serve and saw that those files were not pulled in by Jekyll…?

If it is the latter case, then it is simply because like @mmistakes said above, not all files are pulled in from a theme-gem.
Files outside _layouts, _includes, _sass and assets are not considered as “presentational” files but as “content” files that should ideally be only present at the site.source path


#4

That’s sad :cry:

Is this feature in the backlog? @mmistakes

What about the index.md file? Gem does save that isn’t it.


#5

That’s right, @ashmaroli.


#6

No idea if this feature is in development.
Only files I mentioned above are included in the gem, index.md is not one of them.