Originally posted at https://endaphelan.me/technology/programming/changing-theme-in-jekyll-application.
Follow these steps and you will be able to change the theme in your Jekyll application.
Create a new orphan branch and ensure it is empty.
git checkout --orphan newtheme git rm -rf . git clean -dfx
Now let's add the theme's repository as an upstream remote and pull the files into our branch. I am using Moon theme by Taylan Tatlı.
git remote add upstream https://github.com/TaylanTatli/Moon.git git fetch upstream git pull upstream master
Install Gem dependencies and run your application to see if the previous steps were successful.
bundle install jekyll serve
All okay so far? Good. Now it's time to merge your blog posts, configuration and other custom files.
This will bring in your posts from
git checkout master -- _posts
You can safely merge these files and folders:
README.mdand other custom Markdown files.
- Favicon files.
- Other custom files and directories such as pictures.
Some old files will conflict with ones from your new theme. The safest thing to do here is to copy the file to a new name and merge it manually.
git show master:_config.yml > _config.yml.old
Accidentally overwritten a theme file? No problem:
git checkout upstream/master -- index.md
I recommend manually merging these files:
master with the
git checkout newtheme git merge -s ours master --allow-unrelated-histories git checkout master git merge
Run the application again to see if your changes have come through:
Push your changes:
Leave no evidence of the crime by deleting the
git branch -d newtheme
This solution is adapted from Daniel Pelsmaekerwith's answer on StackOverflow to work with the latest versions of Git, Bundler and Jekyll.