DEV Community

Henrique
Henrique

Posted on • Originally published at Medium on

2

Using WSL2 + Visual Studio Code for Jekyll blogging on Windows 10

If you are like me and have your blog hosted on GitHub pages you are using Jekyll as your blog generation engine. Turns out that Jekyll does not support Windows so you have to do some hacking in order to make it work on Windows. In this post I will show you how to take advantage of WSL2 and Ubuntu 18.04 to install Jekyll and locally run your blog.

What is Windows Subsystem for Linux 2?

The Windows Subsystem for Linux (WSL) is a new Windows 10 feature that enables you to run native Linux command-line tools directly on Windows.

WSL 2 is a new version of the architecture that powers the Windows Subsystem for Linux to run ELF64 Linux binaries on Windows. This new architecture changes how these Linux binaries interact with Windows and your computer’s hardware, but still provides the same user experience as in WSL 1 (the current widely available version). Individual Linux distros can be run either as a WSL 1 distro, or as a WSL 2 distro, can be upgraded or downgraded at any time, and you can run WSL 1 and WSL 2 distros side by side. WSL 2 uses an entirely new architecture that uses a real Linux kernel.

How to install WSL2 is documented here

Visual Studio Remote WSL

If you have VS Code already installed you will need to install the Remote WSL extension so that you are able to run linux commands and applications against your mounted Windows folder where your Jekyll blog is.

Extension is here

After the extension is installed you will see a small icon on the bottom left of VS Code

VS Code Remote icon

What I usually do is open the folder that as the blog before starting the remote session. Once I have the folder open in VS Code I click on the Remote WSL icon and are presented with the following options:

Remote WSL options

You will then choose Remote-WSL: Reopen Folder in WSL (if you had the folder opened). Once everything is finished the icon will change to:

Session established

Now open the terminal window and you will see that the context is your Ubuntu machine and the folder is a mount to your Jekyll blog folder

Installing Jekyll in WSL Ubuntu 18.04

First let's update everything I am running all commands as sudo but you run with the level you want

sudo apt-get update -y && sudo apt-get upgrade -y

Now let's install Ruby

sudo apt install ruby

Check if Ruby was installed

ruby -v

Update your gems

sudo gem update

Install bundler

sudo gem install bundler

And install some dependencies like ruby-dev

sudo apt-get install ruby-dev build-essential dh-autoreconf

And finally install Jekyll

sudo gem install jekyll

Check if Jekyll is installed correctly

jekyll -v

If you get a version back, all is good Now if you want to create a new blog you can run

jekyll new myblog

if you are already with the blog folder opened you can start the server

bundle exec jekyll serve
view raw install.md hosted with ❤ by GitHub

And now you can run your blog locally in Windows 10 with the power of WSL2 and Linux without having to hack your way installing Jekyll on Windows.

Image of Docusign

Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs