Skip to main content

Installing Hugo on Ubuntu

In this guide, we are going to install Hugo on a server running Ubuntu version 22.04.

Installation

  • Install hugo sudo snap install hugo 1

  • Install GIT sudo apt-get install git-all 2

  • Confirm Hugo is installed by checking the version number hugo version 3

Creating First Website

  • Create a new site called quickstart hugo new site quickstart 4

  • Change directory cd quickstart

  • Start a GIT repository git init 5

  • Clone the Ananke theme into the themes directory, adding it to your project as a Git submodule. git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke 6

  • Append a line to the site configuration file, indicating the current theme. echo "theme = 'ananke'" >> hugo.toml 7

  • Start Hugo’s development server to view the site. hugo serve 8

  • Using a web browser navigate to the locally hosted website http://localhost:1313.

Creating First Post

  • To create a new post, run the command hugo new content posts/my-first-post.md. The command will create a new file in the directory content\posts 10

  • Edit the new file using a text editor nano content\posts\my-first-post.md 11

  • Change the draft=false to draft=true in the header section. Then add some markdown content to the file. To save the changes press control + o to exit press control + x. 12

  • Using a web browser navigate to page http://localhost:1313/posts/my-first-post/ 13

Deploying

  • hugo --gc --minify
  • rclone sync --interactive --sftp-host sftp.example.com --sftp-user www-data --sftp-ask-password public/ :sftp:www/

Theme

Adverts