Search code examples
javascripthtmljquerycssjekyll

Can I switch between Jekyll themes on a mouse click?


I am building my website using a Jekyll theme. The basic website is up and running. However, I wanted to provide an option on the UI to change the theme. Is it possible to add a button such that a mouse click on it changes the theme?

Expanding on what I'm asking, Jekyll generates static pages. Is it possible to re-trigger Jekyll from the webpage itself to generate pages with a new _layout and _sass?

One possible approach might be to keep the two themes in different branches, and then change the Github pages publishing source to the new branch. Is this approach possible? Or are there any alternatives?


Solution

  • No, this approach is not possible - if the click would run the generator, it would no longer be a static page.

    What you can do is

    • do the switch on the client side with js, swapping paths to css files or something
    • generate all pages with both themes, and have the button link to the respective other.