0

What Is Hugo and How Does It Work?

 1 year ago
source link: https://www.makeuseof.com/hugo-static-site-generator/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

What Is Hugo and How Does It Work?

By Sharlene Von Drehnen Published 8 hours ago

Hugo is a static site generator that you can use to build content-focussed, fast websites. Learn all about what Hugo can do for you.

Top-down view of a laptop on a person's lap with a coffee cup held nearby

If you’re planning to create a simple, content-driven website, you probably don’t want to spend too much time coding it. This might be the case if you’re creating a business site, blog, or personal portfolio.

Static site generators target these kinds of scenarios. They allow you to spin up a website that lets you focus on your content and its design.

Hugo is one example of a static site generator. It has support for themes, authoring in Markdown, and other benefits besides.

What Is Hugo?

Hugo is a static site generator that allows you to create a website with little to no code. Static site generators usually allow you to write your content in a simple markup language, like Markdown.

The static site generator then converts your content into static HTML files. It applies any templates or styles to your pages before serving them up to the user.

Using Hugo, you can choose from a library of themes and site designs that other people have already built. Once you have downloaded a theme, you can start writing your content. Hugo accepts different formats for you to write your content in.

What Are Hugo Themes?

You can visit the list of Hugo Themes to find one to get started with. You can also select a theme based on different categories, and filter designs made specifically for blogs, portfolios, and more.

List of Hugo Themes Page

You can click on a theme to see more information. Here, you can download the theme to start working on it. You can also preview what the theme would look like once you deploy it.

Example Hugo Site Preview

Most of the themes will have dummy data as placeholders. When you modify the theme, you can change these details however you like.

What Is the Structure of a Hugo Site?

Using a theme allows you to add your content with little to no changes to the code. However, you can still dive into the code if you want to make changes to its structure. Hugo uses Go templates to make use of variables and placeholders within your HTML files.

Example of a Go template with HTML and custom directives

Creating a Hugo project on your computer will automatically generate the default files needed for the project.

Hugo Sample File Structure

The main components of the project include:

  • archetypes: This is where you can store templates that can define any formatting or additional data for each page. When you create a new page, it will be based on a template.
  • assets: This is where you can store any assets, such as your CSS style sheet files.
  • content: This is where you can store the content for your website. You can store each page in a separate file. For example, if you were making a blog, you would use a Markdown file for each post.
  • layouts: Here you can store short, re-usable snippets of HTML code, called shortcodes. You can use these within your content files.
  • public: This contains the files and folders that you can upload and use on a web server when hosting your site.
  • themes: Any themes that you downloaded from Hugo will appear here.

What Are the Benefits of Using Hugo?

Since Hugo is quite lightweight and generates static web pages, your final website and its content can load very quickly. This means users will have little wait time when browsing your site.

All the content is static and does not change once the user is viewing the page. Therefore, you do not have to worry about constant requests to a server. You also do not need to worry about databases, or accounting for dynamic data.

And you don’t need advanced programming skills to be able to work with a Hugo site. However, since you have direct access to the code, you can fully customize it the way you want if you choose to do so.

Using Static Site Generators to Create Websites

Hugo is an excellent static site generator that converts your content into plain HTML files. You can use a wide range of themes and easily preview your site during the design process.

Hugo provides reusable components and a convenient standard file structure, amongst other benefits. But Hugo is just one option. You should continue to research other static site generators that you can use to build a website.

About The Author
62364c8e71ce3-An%20image%20of%20me.jpg?fit=crop&w=100&h=100

Sharlene Von Drehnen (15 Articles Published)

Sharlene is a Tech Writer at MUO and also works full time in Software Development. She has a Bachelor of IT and has previous experience in Quality Assurance and University tutoring. Sharlene loves gaming and playing the piano.

More From Sharlene Von Drehnen

Subscribe to our newsletter

Join our newsletter for tech tips, reviews, free ebooks, and exclusive deals!

Click here to subscribe

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK