Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: gem-based themes inheritance #7344

Open
DirtyF opened this issue Oct 28, 2018 · 11 comments · May be fixed by #7554
Open

feat: gem-based themes inheritance #7344

DirtyF opened this issue Oct 28, 2018 · 11 comments · May be fixed by #7554
Labels
feature has-pull-request Somebody suggested a solution to fix this issue themes 🎨

Comments

@DirtyF
Copy link
Member

DirtyF commented Oct 28, 2018

Summary

Support for parent/child themes allowing users to build upon existing themes.
See benbalter/jekyll-remote-theme#35 (comment)

Motivation

  • develop starter themes and allow to build child themes upon
  • distribute child themes as gems

Guide-level explanation

  • A child theme is a theme than expand an existing gem-based theme

Reference-level explanation

  • Only available for gem-based themes
  • A child can list a theme dependency in its gemspec (and theme/_config.yml ?)
  • Jekyll can apply a parent theme, and a child theme
  • Users have only to declare the child-theme in the main _config.yml

/cc @jekyll/themes @jekyll/minima, @mmistakes, @daviddarnes, @nickgarlis

@daviddarnes
Copy link
Member

This is a concept that I have thought about before, and even something that I thought might already be possible. I'd be interested to discuss this more, especially since this not only brings some exciting features to Jekyll but some possible headaches as well (cue the WordPress child theme flashbacks). This is issue thread the best place to discuss? I'd hate to spam people on a topic that could get really long

@ashmaroli
Copy link
Member

@daviddarnes Go ahead and list down all that you have to say regarding this feature..

@daviddarnes
Copy link
Member

daviddarnes commented Oct 28, 2018

Alrighty, I'll just list up the positive and possible negative implications of this:

Positive

  1. Bundling of code for multiple sites; I've worked on WordPress multi-sites that used a parent and child theme system to share code, this would be a similar feature
  2. Faster development of theme ecosystem; More themes can be made at a more rapid pace
  3. Reduced complexity of theme creation; Anyone who's new to theming can get involved without starting from scratch
  4. Boilerplate standards can be produced causing better theme code quality

Negative

  1. Increased complexity when using multiple themes. Tracking down a bug, style or value could prove annoying
  2. Inheritance, how will it work and will it be consistent?
  3. Conflicts with the simple nature of Jekyll. There has been a lot of powerful features added to Jekyll, including theming, but is this going too far

I've numbered these so they can be easily referenced. I'll be honest, those negatives are more me being devils advocate to myself. I've put them incase people have similar thoughts or are able to justify them better than I can

@DirtyF
Copy link
Member Author

DirtyF commented Oct 28, 2018

@daviddarnes Thanks for laying things out, it's best if we think things through together 👍

Here's how I envision this feature:

  • This should not change anything for end-users, they can use child themes as they use themes today. You would still be using a single theme (a child theme, a parent theme or a regular theme),
  • We should log the theme name (path?) in debug mode, e.g.:
    Liquid Exception: Liquid syntax error (line 6): Unknown tag 'this_will_not_work' in <theme_name>/_layouts/home.html
  • Inheritance will work like it's already working today when you override a theme with local folders, except we add a new level: parent theme > child theme > local files
  • same for config files: parent theme config > child theme config > local config
  • local files always win on theme files
  • It's up to theme developers to declare the theme they're building upon, (through child theme config and gemspec )

@daviddarnes
Copy link
Member

@DirtyF it just dawned on me why I thought this was possible, because I thought you could already import a theme gem just like a Jekyll gem plugin anyway. This is the convention we're talking about yes? What currently prevents us importing a theme into another theme as a gem?

@DirtyF
Copy link
Member Author

DirtyF commented Oct 28, 2018

What currently prevents us importing a theme into another theme as a gem?

I just tried it. I overode minima and publish the theme gem: https://rubygems.org/gems/jekyll-theme-minima

Now when I create a new jekyll site and specify the child theme, it won't build:

Trace
Dependency Error: Yikes! It looks like you don't have minima 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 -- minima'
bundler: failed to load command: jekyll (/Users/frank/gems/bin/jekyll)
Jekyll::Errors::MissingDependencyException: minima
  /Users/frank/code/jekyll/jekyll/lib/jekyll/external.rb:70:in `rescue in block in require_with_graceful_fail'
  /Users/frank/code/jekyll/jekyll/lib/jekyll/external.rb:58:in `block in require_with_graceful_fail'
  /Users/frank/code/jekyll/jekyll/lib/jekyll/external.rb:57:in `each'
  /Users/frank/code/jekyll/jekyll/lib/jekyll/external.rb:57:in `require_with_graceful_fail'
  /Users/frank/code/jekyll/jekyll/lib/jekyll/plugin_manager.rb:44:in `block in require_theme_deps'
  /Users/frank/code/jekyll/jekyll/lib/jekyll/plugin_manager.rb:41:in `each'
  /Users/frank/code/jekyll/jekyll/lib/jekyll/plugin_manager.rb:41:in `require_theme_deps'
  /Users/frank/code/jekyll/jekyll/lib/jekyll/plugin_manager.rb:20:in `conscientious_require'
  /Users/frank/code/jekyll/jekyll/lib/jekyll/site.rb:117:in `setup'
  /Users/frank/code/jekyll/jekyll/lib/jekyll/site.rb:32:in `initialize'
  /Users/frank/code/jekyll/jekyll/lib/jekyll/commands/build.rb:30:in `new'
  /Users/frank/code/jekyll/jekyll/lib/jekyll/commands/build.rb:30:in `process'
  /Users/frank/code/jekyll/jekyll/lib/jekyll/command.rb:89:in `block in process_with_graceful_fail'
  /Users/frank/code/jekyll/jekyll/lib/jekyll/command.rb:89:in `each'
  /Users/frank/code/jekyll/jekyll/lib/jekyll/command.rb:89:in `process_with_graceful_fail'
  /Users/frank/code/jekyll/jekyll/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
  /Users/frank/gems/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
  /Users/frank/gems/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
  /Users/frank/gems/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
  /Users/frank/gems/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
  /Users/frank/gems/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
  /Users/frank/code/jekyll/jekyll/exe/jekyll:15:in `<top (required)>'
  /Users/frank/gems/bin/jekyll:23:in `load'
  /Users/frank/gems/bin/jekyll:23:in `<top (required)>'

@DirtyF DirtyF changed the title feat: gem-based themes inheritence feat: gem-based themes inheritance Oct 28, 2018
@daviddarnes
Copy link
Member

I guess this is what needs to be fixed in order for it to work. Do we need to establish behaviour of child/parent themes too?

@daviddarnes
Copy link
Member

Any more progress on this topic? Clearly not a huge demand, but certainly had potential

@DirtyF
Copy link
Member Author

DirtyF commented Nov 9, 2018

No, Jekyll core team is very limited at the moment. Any help is warmly welcome if someone is interested in contributing.

@IssueHuntBot
Copy link

@issuehuntfest has funded $60.00 to this issue. See it on IssueHunt

@DirtyF DirtyF removed the discussion label Feb 4, 2019
@seshrs seshrs linked a pull request Mar 5, 2019 that will close this issue
@jekyllbot jekyllbot added the has-pull-request Somebody suggested a solution to fix this issue label Mar 5, 2019
@IssueHuntBot
Copy link

@0maxxam0 has funded $2.00 to this issue.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature has-pull-request Somebody suggested a solution to fix this issue themes 🎨
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants