Learn how to set up a blog server development client with Hugo + GitLab Pages using Visual Studio Code. It’s free.
Goal
Below is a configuration diagram (example) of a blogging environment with Hugo + GitLab Pages. The goal here is to build a Visual Studio Code environment on a Windows PC that modifies GitLab's Hugo repository assets, modify the site, and build/publish it.
Assumption
This explanation assumes that you have followed the "Server with Hugo + GitLab Pages" and prepared a server environment built with the GitLab Pages/Hugo template.
Procedure
Install Git on your PC
-
Install Git on your PC 1. Defaults except as follows.
- Select Visual Studio Code for
Choosing the default editor used by Git
. - Select
Use external OpenSSH
forChoosing the SSH executable
2.
- Select Visual Studio Code for
-
At the command prompt, run the following
> git config --global user.name "(name of user for local Git environment)" > git config --global user.email "(email address of user for local Git environment)"
Install Visual Studio Code on your PC
Install Visual Studio Code on your PC.
Download GitLab's Hugo repository assets in Visual Studio Code
Press
Source Control
icon on the left bar of Visual Studio Code.Press
Clone Repository
button.-
Specify
Repository URL or... Enter the repository URL of the Hugo project in GitLab in the
input area`, and press the Enter key.How to find the repository URL is as follows.
- Log in GitLab by browser, and open
Repository
-Files
screen of Hugo project. - Press
Clone
button, and displayedClone with HTTPS
is the repository URL.
- Log in GitLab by browser, and open
You will be asked for your GitLab login username/password, enter it and press Enter.
You will be asked where to download the assets. Enter the information and press the Enter key, and a project directory will be created under the directory you specified, and the files will be downloaded under that directory.
When asked if you want to open the downloaded assets, select Open.
When asked if you trust the assets, select Trust, and the downloaded assets will appear in the left tree.
Change Hugo repository assets in Visual Studio Code
Edit any file in Visual Studio Code.
Upload Hugo repository assets modified in Visual Studio Code to GitLab
Press
Source Control
icon on the left bar.Press
+
(stage all changes) button underChanges
in the left pane, and the modified files will move toStaged Changes
.Enter the changes in the
message
input area at the top of the left pane.Press
commit
button inSource Control
at the top of the left pane, and the changed files will disappear from thestaged changes
.Press
Synchronize Changes
button underSource Management
at the top of the left pane, and the asset will be upload to GitLab and automatically start the build.
Check the build/publish results done automatically in GitLab
Log into GitLab with a browser, open the Hugo project page, and see the changes you entered in Visual Studio Code and the
✓
(Pipeline: passed) icon appear above the file list.Open the site in a browser and verify that the changes have been reflected.
-
You can also use WSL (Ubuntu), but I don't recommend it if you only use it for blog development, because it eats up space and expands the time and effort of preparation and management. ↩
-
Since OpenSSH is included from the beginning in recent Windows, there is no need to install it again. If you are worried, you can choose
Use bundled OpenSSH
(default). ↩
Top comments (0)