-
Notifications
You must be signed in to change notification settings - Fork 3
Hugo
This README provides detailed instructions on how to set up a Hugo site on Ubuntu and macOS.
To install Hugo on Ubuntu, use the snap package manager:
sudo snap install hugoOn macOS, you will first need to install Homebrew if you haven't already. Follow the installation instructions on https://brew.sh/.
After installing Homebrew, you can install Hugo:
brew install hugoNavigate to your desired directory (e.g., git):
cd gitCreate a new Hugo site:
hugo new site my-hugo-blogThis command creates a new Hugo site in /home/git/my-hugo-blog.
-
Add Content:
You can add content by creating new files:
hugo new <SECTIONNAME>/<FILENAME>.<FORMAT>
-
Start the Server:
To view your site locally, start Hugo's built-in live server:
hugo server
Choose a theme from Hugo Themes and download it into the themes directory.
Initialize a Git repository if you haven't already:
git initFor example, to add the Archie theme:
git submodule add git@github.com:joone/archie.git themes/archie-
Copy the Example Site:
Copy the contents from the theme's
exampleSiteto your site's root:cp -R themes/archie/exampleSite/* .
-
Modify
config.toml:Edit your site's configuration file:
vi config.toml
To write a new post:
hugo new posts/hello.mdTo add images or other static files, place them in the static/images directory.
For more detailed instructions and documentation, visit the Hugo Quickstart Guide and the Hugo Documentation.
Adjust the file paths and commands as necessary to match your specific setup or preferences.
You can add images directly in the content folder alongside your post in Hugo, which is particularly useful for organizing your content and images together, especially when using page bundles. Hugo supports page bundles, where a post and its related resources like images are grouped together in the same directory. Here's how you can do it:
-
Create a Page Bundle: Instead of creating a single markdown file for your post, create a directory for your post under
content/posts/. For example, if your post is namedhello.md, create a directory namedhelloand rename your post toindex.mdinside this directory.content └── posts └── hello ├── index.md └── image.jpg -
Add Your Image: Place your image (
image.jpgin this case) inside thehellodirectory alongsideindex.md. -
Reference the Image in Your Post: In your
index.md, reference the image using a relative path. Since the image is in the same directory as your markdown file, you don't need to specify a full path from the root. You can reference it like this:- Using Markdown:

- Using HTML:
<img src="image.jpg" alt="Alt text" title="Optional title" />
- Using Markdown:
By using this approach, the image is tightly coupled with the post, making it easier to manage and move around if necessary. When you build your site, Hugo understands the structure and correctly processes the files, ensuring the image is displayed with your post.