Build the static site
You can build a Jekyll site from scratch or you can use already created template and adjust it for your needs. I have decided to go with the second approach. I’ll be using a jekyll-clean-dark
template.
To build your site with Jekyll you need to run in your project directory:
1
jekyll build
Should you have any issues add --trace
to your command which will be more verbose.
After you build your site you can copy the content of _site
to your hosting
Run locally
To run Jekyll locally you have to have the jekyll
gem installed.
In powershell you can do this the following way (first select your installed ruby):
1
2
3
PS C:\Users\user> gem list | sls jekyll
jekyll (4.1.0)
Next you go to your Jekyll project directory and configure your _config.yml
. In my case ..\jekyll-clean-dark
.
- To run local Jekyll instance (using simple WEBbrick server):
1
jekyll serve --baseurl=''
This will run Jekyll on a localhost
(127.0.0.1
) on a default port 4000
.
Error staring Jekyll
When you start Jekyll and you get the following message, then probably some other process is already running at the port:
C:/app_scoop/apps/ruby/2.7.0-1/lib/ruby/2.7.0/socket.rb:201:in 'bind': Permission denied - bind(2) for 127.0.0.1:4000 (Errno::EACCES)
To find out if something is blocking your port (in PowerShell):
1
2
3
PS C:\Users\xxx> netstat -ano -p tcp | sls 4000
TCP 0.0.0.0:4000 0.0.0.0:0 LISTENING 9000
The last column gives you the PID
of the running process, so you need to find it out.
One of the simplest way is to do it via tasklist
:
1
2
3
PS C:\Users\xxx> tasklist | sls 9000
nxd.exe 9000 Services 0 5 328 K
The default port is 4000
, but as shown there is already nomachine’s nxd.exe
running on the port. The solution is to change the default port via the --port <int>
setting.
- To start Jekyll on non-default port
4001
you need to run it like this:
1
jekyll serve --baseurl='' --port 4001
Regenerate tags
If new an article is written with new tag(s) you need to generate tag(s) for the tags page. For that you need to run script which is automagically prepared at:
1
http://127.0.0.1:4001/admin/
I have added a PowerShell section which prepares all the tags to be run in PowerShell. The reason why it the script is so complex is that in the PowerShell 5 it is really a pain to prepare UTF-8 files without BOM. Thank you Microsoft, not!
First enter the ..\tag
directory of the project.. You copy&paste either the bash section, for linux, or the PowerShell section for Windows. Then run the generated lines.