Technique Memo

First try

03 Mar 2024

Using Jekyll to Generate a Static Site

1. Installation

Install Jekyll: gem install jekyll Install Bundler: gem install bundler

2. Create a New Site

jekyll new [site_name]

3. Build and Preview

cd [site_name]
bundle exec jekyll serve

(Open http://localhost:4000 in your browser)

There are two main ways to specify the IP address and port for accessing your Jekyll site:

Method 1: Modifying the Configuration File

Edit the _config.yml file located in the root directory of your Jekyll project. Add the following configuration options:

host: <your_ip_address>
port: <your_port_number>

Replace <your_ip_address> with the IP address you want to bind to. Replace <your_port_number> with the port number you want to use.

Example:

host: 192.168.1.100
port: 4001

Method 2: Using Command Line Arguments

When starting Jekyll, use the --host and --port arguments with the jekyll serve command.

jekyll serve --host <your_ip_address> --port <your_port_number>

Replace <your_ip_address> with the IP address you want to bind to. Replace <your_port_number> with the port number you want to use.

Example:

jekyll serve --host 192.168.1.100 --port 4001

Important Notes:

By default, Jekyll listens on the local loopback address (127.0.0.1) on port 4000. Specifying an IP and port allows you to access your Jekyll site from other devices on your local network or even the internet. Make sure to open any necessary firewall ports on your server to allow external access.

5. Build and Deploy

bundle exec jekyll build

Upload the contents of _site to your web host.

Further Resources:

Jekyll Docs: https://jekyllrb.com/docs/ Jekyll Tutorial: https://www.youtube.com/watch?v=T1itpPvFWHI

Tweet