Use a Jekyll theme
To use an open source Jekyll theme available on github.com:
- Fork that repo to your own account (you may not need to fork it to have it works, but to give credits to the author, I highly recommend to do so). For example: jekyll-theme-chirpy.
- Clone the repo to your local disk:
1
git clone https://github.com/username/repo_name
- Bundle the website:
1
bundle install
Some Jekyll themes specify versions of dependencies in the Gemfile. If any version related problem happens, check the Gemfile.
- Serve the website. Most of the time, we can just run:
1
bundle exec jekyll serve
But be sure to read the manual of the Jekyll theme you are using. For example, in jekyll-theme-chirpy, the author provides a bash file to build extra widgets and serve the website. For this case, run:
1
bash tools/run.sh
- Open http://localhost:4000/ to see the website.
Publish a website on Github
To publish a website using Git commands.
- Initiate Git:
1
git init
- Add changes:
1
git add .
- Commit changes:
1
git commit -m "any description of the change"
- Connect with the remote repo:
1
git remote add origin [url of your repo]
- Push to remote:
1
git push -u origin master
- Open the Settings of the repo, in GitHub Pages -> Source section, select master branch.
- Wait a few seconds, you will see “Your site is published at https://username.github.io/repo_name/”. Click this url, you will see your website is published.
Special notes for the jekyll-theme-chirpy: Before using git commands, jekyll-theme-chirpy needs to build categories and tags, so run this first:
1
bash tools/run.sh
Then you will see a folder ‘.container’. Copy everything in this folder and replace files in the root directory. Finally, go for git step 1 as shown above.
The author did provide some tools (in /tools) helping to skip this copy-paste step, but they were not working very well in my end, so I choose to just use copy and paste.
Other tips
If permission is needed for the folder:
1
sudo chown -R $USER ~/folder_name