Two years ago, I firstly learned Git, GitHub and built my first Jekyll site hosted on GitHub on Windows. However, because Jekyll does not support Windows without using a virtual machine, I had to upload new materials of my sites to GitHub and watch if the formatting and content were shown correctly on the site every time I wanted to update my site.
Since 2017, I have switched my working environment almost entirely to Ubuntu, but I still have not got Jekyll installed on my computer and tested my site locally, which is pretty bad for a person who studies computer science. Today, somehow I get a chance to get Jekyll installed and successfully hosted my site locally, which I should have done two years ago. Here I documented the process and caveats for my future references.
To properly install Jekyll, the following software and packages are necessary.
$ sudo apt-get update $ sudo apt-get install ruby ruby-dev make gcc $ sudo gem install jekyll bundler $ sudo apt-get install nodejs
Go to the directory of your website containing the
$ bundle install
If some errors happen, try this before running the above command:
$ sudo gem update --system
Host Jekyll Site Locally
Go to the directory of the Jekyll site.
# url: https://leimao.github.io # Host Jekyll site on GitHub url: # Leave blank. Host Jekyll site locally on http://127.0.0.1:4000/ by default.
Start Jekyll server:
$ bundle exec jekyll serve
The following message will show if the server started successfully.
Configuration file: /home/marine/Workspace/leimao.github.io/_config.yml Source: /home/marine/Workspace/leimao.github.io Destination: /home/marine/Workspace/leimao.github.io/_site Generating... done. Auto-regeneration: enabled for '/home/marine/Workspace/leimao.github.io' Configuration file: /home/marine/Workspace/leimao.github.io/_config.yml Server address: http://127.0.0.1:4000/ Server running... press ctrl-c to stop.
Now go to
http://127.0.0.1:4000/ in a web browser to view the site.
Changing the localhost url is feasible. But I am not going to learn how to do it for now.
So far, everything looks OK except that the coding block does not show properly in the localhost. Someone has also reflected similar problems on GitHub. But I have not found a solution to solve this problem.