Post

Set Up Your Blog On Github

Set Up Your Blog On Github

There have been a lot of instructions about how to set up a blog on Github, but it still cost me 3 nights to finish. So I believe that recording what I had done when built this blog may help others who meet the same issues.

Run Your Blog Locally

Whether to test or to see what you’ve changed faster, it is recommended to run your blog locally, below is how to set up it.

Install Dependencies for Jekyll

My system is Ubuntu-22.04.3, if yours is mac, windows or other linux, here is the place for you to get more information Jekyll Docs: installation.

1. Install Ruby:

1
2
sudo apt update
sudo apt-get install ruby-full build-essential zlib1g-dev

Avoid installing RubyGems packages (called gems) as the root user. Instead, set up a gem installation directory for your user account.

It is a good suggestion, though I did not follow.

2. Add environment variables to configure the gem installation path

Add variables below to .zshrc if you use zsh or .bashrc if you use bash.

1
2
3
# Install Ruby Gems to ~/gems
export GEM_HOME="$HOME/gems"
export PATH="$HOME/gems/bin:$PATH"

3. Install Jekyll and Bundler

1
gem install jekyll bundler

4. Change Sources if You Are in China

  • For gem
    1
    
    gem sources --add https://mirrors.tuna.tsinghua.edu.cn/rubygems/ --remove https://rubygems.org/
    
  • For bundler
    1
    
    bundle config mirror.https://rubygems.org https://mirrors.tuna.tsinghua.edu.cn/rubygems
    

5. Trouble Shooting

  • Bundler::PermissionError

I got the error below when excuse gem install jekyll bundler:

1
Bundler::PermissionError: There was an error while trying to write to `/xxx/cache/xxx.gem`. It is likely that you need to grant write permissions for that path.  

Using gem install jekyll bundler --user-install instead helped for me.

  • zsh: command not found: jekyll

When I wanted to use jekyll command, I ran into this error zsh: command not found: jekyll. I fixed it by adding this line to .zshrc.

1
export PATH=$PATH:/home/YOUR_USER_NAME/.local/share/gem/ruby/3.0.0/bin

Choose a Jekyll Theme

You can pick up a theme from here Jekyll Theme.

Or just generate a default theme using jekyll new YOUR_BLOG_NAME

Visit Jekyll Doc for more information.

Set up Your Blog on Github

I choose Chirpy as my theme, if you are the same, you can visit Getting start with Chirpy for more information.

Or, you can follow other theme’s instruction or just visit https://pages.github.com/.

Have a nice day!

This post is licensed under CC BY 4.0 by the author.