install hugo on mac os
Table of Contents
- Prerequisites: Install Homebrew
- Installing Hugo
- Verification
- Adding a Template
- Editing Pages
- Understanding the Directory Structure
- Conclusion
Installing Hugo on MacOS
Hugo is a powerful and fast static site generator. If you’re using MacOS, the installation process is straightforward, thanks to the Homebrew package manager. Below are the steps to install Hugo on your MacOS system.
Prerequisites: Install Homebrew
Before installing Hugo, you’ll need to have Homebrew installed. If you haven’t done so, you can install Homebrew by entering the following command in your terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
After the installation is complete, you might want to run brew update
to make sure you have the latest package definitions.
Installing Hugo
With Homebrew installed, getting Hugo up and running is a breeze. In your terminal, simply type:
brew install hugo
This command tells Homebrew to fetch the latest version of Hugo and install it on your system.
Verification
To ensure that Hugo was installed successfully, you can check its version:
hugo version
If everything went as expected, you’ll see the version of Hugo displayed in your terminal.
Creating a new Site
hugo new site yoursite
Adding a Template
cd yoursite
git submodule add --depth=1 https://github.com/canhtran/maverick.git themes/maverick
Editing Pages
To edit a page in Hugo:
- Navigate to the
content
directory. - Locate the markdown file for the page you wish to edit.
- Open the file in a text editor and make your changes. Save when done.
Understanding the Directory Structure
A standard Hugo site has the following directory structure:
- content/: This is where your pages live. Each page is a markdown file.
- static/: Any static files (images, CSS, JS) can be placed here.
- content/posts/: This is where your blog posts are found.
- layouts/: Custom templates and layout overrides are stored here.
- themes/: This directory holds the themes for your site.
- config.toml: The site-wide configuration file.
It’s crucial to understand this structure as it allows you to organize your content efficiently and make the most of Hugo’s features.
Conclusion
That’s it! With these simple steps, you’ve installed Hugo on MacOS using Homebrew. Now, you’re ready to start building your static site or blog with Hugo. Happy coding!