Hugo is an open-source, fast, and modern static site generator is written in golang where you write your content in Markdown, which is a massive plus for me since I use obsidian for my note-taking.
Cloudflare Pages is a free way to host and auto-build your site when pushed to your GitHub.
Cloudflare sites come with built-in SSL, 500 builds a month. That should be plenty for most it comes to 16 Git pushes a day.
The only thing that will cost is buying a domain, Cloudflare will give you a free one (https://yourSite.pages.dev/), but I would suggest buying one.
In this step-by-step tutorial, we will be going through how to install Hugo with the hello-friend theme, set up a site with Cloudflare Pages, and make a simple post.
run the create repo commands from git in your YOUR-BLOG folder
vim .gitignore
paste into the .gitignore file:
# Created by https://www.toptal.com/developers/gitignore/api/hugo,visualstudiocode# Edit at https://www.toptal.com/developers/gitignore?templates=hugo,visualstudiocode### Hugo #### Generated files by hugo/public/
/resources/_gen/
/assets/jsconfig.json
hugo_stats.json
# Executable may be added to repositoryhugo.exe
hugo.darwin
hugo.linux
# Temporary lock file while building/.hugo_build.lock
### VisualStudioCode ###.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
# Local History for Visual Studio Code.history/
# Built Visual Studio Code Extensions*.vsix
### VisualStudioCode Patch #### Ignore all local history of files.history
.ionide
# Support for Project snippet scope.vscode/*.code-snippets
# Ignore code-workspaces*.code-workspace
# End of https://www.toptal.com/developers/gitignore/api/hugo,visualstudiocode
Now you want to pick your theme. You can find plenty of choices on Hugo’s theme site https://themes.gohugo.io
I will be using the hello-friend in this install
You can edit the site by vim, nano or VScode
I would suggest opening the site in VScode and editing from there. You will probably jump between files when first setting up the site.
Open up your config.toml and paste the default config file found on hello-friend. After saving it, you can start up the site with: hugo serve -D -D flag makes your draft pages show up on the site while editing
Now you can make some changes to the config.toml file, and changes should happen in real-time when you save it.
Make a markdown file in your posts folder and manually put the Front matter in the file
Use Hugo’s built-in command hugo new posts/firstPost.md
If the site is up and running, it should refresh immediately and add the page.
Use a simple markdown file or use a folder struckture called page bundles
Make a yourPost.md file and put everything in that
Make a folder yourPost with index.md, photos, and other resources for that post
Hugo folder with page bundle structure and single file structure
Now let’s look into changing some settings in the markdown post file. The same syntax work for both structures.
The setting for the posts is also called Front matter. Again, there are many variables to choose from, and I will go through the ones I use the most.
description: Put the post’s caption underneath the headline. It’s optional since you can use the <–mo re–> in the post itself to split where the caption ends
slug: Is the last segment of the URL
tags: are the # tag
cover: is the path to the cover image, more info here
draft: change to false to make the page live
---
title: hugo site
# description: hugo site
slug: hugo
cover: "img/test.jpg"
date: 2022-06-28T08:09:15+02:00
draft: true
tags:
- Hugo
- blog
- website
---
If you're looking for an excellent way to backup or share your dotfiles, using bare git is a simple and quick way to keep your dotfiles up to date.
<!--mo re--># remove space so it --more--
blah blah blah
The website structure in the content follows the directory structure
if your posts/howto/yourpost.md or posts/howto/yourpost/index.md both would get the url http://YourSite.com/posts/howto/yourpost
Now that you have the site configured and a post on it, you can generate the website inside your website folder. Use the command hugo -v -v is for verbose in case of an error. Your site is in your public folder.