Here’s a short practice you can try with Hugo:
- Create a New Site: Start by creating a new Hugo site using the “hugo new site” command. Give your site a name and open the folder in your code editor.
- Choose a Theme: Browse the available themes on the official Hugo website or on the GitHub repository. Choose a theme you like and download it into the “themes” folder of your site. You can use the following command to download a theme from the GitHub repository:
phpCopy codegit clone https://github.com/<username>/<theme-name>.git themes/<theme-name>
- Customize Your Site: Open the “config.toml” file in the root directory of your site and edit it to add your site’s title, description, and other settings. You can also customize the theme by editing the theme’s HTML and CSS files in the “themes” folder.
- Create a New Page: Use the “hugo new” command to create a new page in your site. For example, you can create a new blog post by running the following command:
sqlCopy codehugo new blog/my-first-post.md
Open the new Markdown file in your code editor and add some content.
- Preview Your Site: Run the following command to start a local development server and preview your site in your web browser:
Copy codehugo server -D
Navigate to http://localhost:1313/ in your web browser to see your site.
- Build Your Site: When you’re ready to deploy your site, run the following command to build the static files:
Copy codehugo
This will generate a “public” folder containing all the files needed to deploy your site.
Congratulations! You’ve now built a simple Hugo website with a custom theme and a new blog post. From here, you can continue to explore Hugo’s many features, such as creating custom layouts, adding menus and widgets, and integrating with third-party services. With its ease of use and wide range of customization options, Hugo is a great choice for building fast, modern, and responsive websites.