Create Static WebSite
Introduction
The content of this post is to show you how to create a static website in an easy way, using a framework and themes.
The post will be very easy and short… so, let’s proceed..
Framework
The Framework that we will to use is HUGO.
I don’t want to stress you with a lot of info about it.
If you are curious, you can check:
How To
We havo to install the framework before to use it (reallY?! :D )
We will use different tools depending by the OS of your PC.
GIT is mandatory. Please, install it if not present in your PC.
1 Install
- Windows –> We will use Chocolatey
choco install hugo -confirm- MacOS –> We will use Homebrew
brew install hugo- Linux
brew install hugo2 Create e new WebSite
It’s very simple. Just write this code in terminal
hugo new site YOUR_SITE_NAME3 Add a Theme
The theme of this WebSite is Hermit.
I’ll show you how to install it
cd YOUR_SITE_NAMEgit init
git submodule add https://github.com/Track3/hermit.git themes/hermitThe code before just download the theme. Now, we have to configure the web site with the new theme:
echo theme = \"hermit\" >> config.toml4 Configure the WebSite
Before to compile the WebSite, you have to set-up some configurations in the config file.
Just open the file config.toml with VisualStudioCode (for example) and edit it following this example:
https://github.com/Track3/hermit/blob/master/exampleSite/config.tomlSimply, add what you need for your WebSite
5 Create a Page
Now, it’s time to create your first static page: \
hugo new posts/my-first-post.mdAs you can see, the path is posts/. This path matches with the voice declared in the config.toml \
[menu]
[[menu.main]]
name = "Posts"
url = "posts/"
weight = 10So, this means that, if you want to create a “folder” to collect other posts (because of different argument, for example), you have to configure the folder in the configuration and run the command to create the static page \
hugo new FOLDER_NAME/PAGE_NAME.md5.1 Edit the WebPage
Just open the .md file with an editor like VSCode. You have to use the markdown to write the content.
As you can see, the framework will not create an empty file:
---
title: "PAGE_NAME"
date: 2022-10-03T17:58:27+02:00
draft: true
toc: false
---If you want to add TAGS or a background image, just inser this:
images:
- https://picsum.photos/1024/768/?random
tags:
- MyDaily
- Software
- Security7 Start the Server!
Now it’s time to see the results.
Just run this in the terminal:
hugo server -Dand open the url http://localhost:1313
8 Build the WebSite
Very simple. Just run: \
hugo -DLast
That’s all!
Have fun!