Posts Creating a Github Page
Post
Cancel

Creating a Github Page

Use a Jekyll theme

To use an open source Jekyll theme available on github.com:

  1. 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.
  2. Clone the repo to your local disk:
    1
    
    git clone https://github.com/username/repo_name
    
  3. 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.

  4. 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
    
  5. Open http://localhost:4000/ to see the website.

Publish a website on Github

To publish a website using Git commands.

  1. Initiate Git:
    1
    
    git init
    
  2. Add changes:
    1
    
    git add .
    
  3. Commit changes:
    1
    
    git commit -m "any description of the change"
    
  4. Connect with the remote repo:
    1
    
    git remote add origin [url of your repo]
    
  5. Push to remote:
    1
    
    git push -u origin master
    
  6. Open the Settings of the repo, in GitHub Pages -> Source section, select master branch.
  7. 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
This post is licensed under CC BY 4.0 by the author.

Comments powered by Disqus.