Create a new page using Hugo Static Site Generator
USE CASE
To instruct an average internet user how to create a page using Hugo Static Site Generator. This guide assumes that Hugo is already installed and configured and Visual Studio Code is installed. The guide refers to this particular user scenario. An example of a user could be a junior Technical Writer.
TIME TO COMPLETE: est. 30 min
-
Open Visual Studio Code.
-
Go to Open folder and search for the
tech-scribefolder. -
From the top menu open a new terminal:
Terminal > New Terminal. -
In the terminal, the command to create a new page:
hugo new content/posts/your-post.mdReplace
your-postwith the name of your post. Insert a hyphen (-) in place of spaces. Keep the.mdextension.
You’ll receive the following message in the terminal once the page is created:
Content "..." created -
Go to the Explorer sidebar, and click on
your-post.mdto select it.
The folder and the file are highlighted in green. -
Hugo creates an empty file containing metadata ( “front matter”) at the top of the page.
Example:---
title: "Your Post"`
date: 2024-11-16T13:56:34+01:00
draft: true
---Replace
trueby false. The page is now no longer in the draft mode
and the updates will be visible after the publication. -
Add content to your page: paste the text formatted in Markdown you’ve exported from the Google Docs (
File > Download > Markdown).
For Windows: UseCtrl + VFor Mac:Command (⌘) + V -
In the terminal, type
hugo serverto check that the page displays correctly.
Hugo builds the page and displays the related messages in the terminal. -
In the terminal, hover over http://localhost:1313/ and then click on
Follow linkto access the preview of the page in the browser.
Check if the page displays correctly. -
Press
Ctrl+Cto stop the preview.
Result: Your page is now ready to be uploaded to GitHub.
Next step
Upload Hugo page to GitHub
Troubleshooting
Common Hugo Errors