Hugo is a fast and efficient static site generator that allows you to create beautiful, responsive websites with ease. It's perfect for personal blogs, portfolios, documentation sites, and more. In this blog series, we'll explore the fundamentals of creating static websites with Hugo.
Before you start building your website, you'll need to install Hugo. You can download the latest version from the official Hugo website: https://gohugo.io/
Once downloaded, follow the installation instructions for your operating system.
To create a new Hugo site, use the following command:
hugo new site my-website
Replace "my-website" with your desired site name.
Hugo organizes your site content in a structured folder hierarchy. Here's a brief overview of the key folders:
To create a new page, use the following command:
hugo new about/index.md
This will create a new page file named "index.md" in the "about" subfolder within the "content" directory.
Open the newly created "index.md" file and start writing your page content. Here's a basic example:
---
title: "About Me"
---
Welcome to my about page!
This is a simple paragraph about me and my website.
After writing your content, build your site using the following command:
hugo
Hugo will generate the static HTML files for your site in the "public" folder.
To view your website, open the "public" folder and open the "index.html" file in a web browser.
To create a new blog post, use the following command:
hugo new posts/my-first-post.md
Open the newly created "my-first-post.md" file and write your post content. You can use Markdown syntax to format your text.
You can add categories to your posts using front matter. For example:
---
title: "My First Post"
date: 2023-10-26T10:00:00Z
categories: ["hugo", "static-sites"]
---
This is my first blog post.
Build your site and view the new post using the steps mentioned earlier.