There are many themes for Jekyll, e.g. https://github.com/jekyll/jekyll/wiki/Themes.
What is the easiest way to switch to a new theme in an EXISTING Jekyll installation?
Under your repository name, click Settings. In the "Code and automation" section of the sidebar, click Pages. Under "GitHub Pages," click Choose a theme or Change theme. On the top of the page, click the theme you want, then click Select theme.
This is what I did to change the theme of an existing Jekyll installation. Adjust these instructions to suit your needs.
We create a new orphan branch newtheme and ensure it's empty.
git checkout --orphan newtheme git rm -rf . git clean -dfx Then we pull the theme files into it by adding the theme as an upstream remote. In this example I pull John Otander's Pixyll theme's master branch.
git remote add upstream https://github.com/johnotander/pixyll.git git fetch upstream git pull upstream master Build the theme and test it.
bundler install jekyll serve Now we merge our posts, configuration, etc. You can use Git checkout to copy a file or folder from your old Jekyll site. Note that this will overwrite the theme's file if it exists.
git checkout master -- _posts Alternatively, you can copy a file under a new name, for example to merge it manually.
git show master:_config.yml > _config.yml.old If you accidently overwrote a theme file, you can restore it.
git checkout upstream/master -- about.md These are the files I had to copy, merge, adjust or remove:
_posts folder._drafts folder._config.yml configuration file.Gemfile gem file.CNAME file (for GitHub pages).Rakefile (if any).Commit your changes, and don't forget to test the theme again.
Finally we replace our existing master branch with the new newtheme branch. Assuming we're on the newtheme branch:
git checkout newtheme git merge -s ours master git checkout master git merge newtheme Push the changes.
git push And clean up the local newtheme branch.
git branch -d newtheme That's it! You've successfully replaced your theme. If there's anything I missed, or you have anything to add, please leave a comment.
If at any later point you want to update the theme to include the latest upstream changes, simply:
git pull upstream master And fix any merge conflicts. Here I assume the upstream remote is still set to the theme's repository (you can check this with git remote -v).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With