Blogging with Hugo and GitLab (2): Local Development Setup

While you can edit pages online in GitLab (e.g., through Web IDE, which also allows to preview Markdown pages), a local development environment of Hugo provides the best support of “what you see is what you get”.

Environment

  • macOS Sierra 10.12.6.
  • Hugo v0.54.0.

Create a local repository

With the website repository hosted on GitLab, we can clone the repository to local.

  1. Clone your website repository to local.

    git clone https://gitlab.com/username/username.gitlab.io.git
    
  2. Configure your GitLab account email within the local repository, which will be used as the identification for all change commit.

    git config user.email "example@email.com"
    

    The updated account information can be verified in .git/config:

    [user]                                                                           
    email = example@email.com
    

Install Hugo to local

  1. Install Homebrew in macOS.

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    
  2. Install Hugo.

    brew install hugo
    

    Verify the installation by viewing the Hugo version:

    hugo version
    

Start the Hugo server

Start the Hugo server with “drafts” enabled, which will show all pages including drafts on the local server.

hugo server -D

Now you will be able to view your website locally at: http://localhost:1313.

The Hugo server will keep running until you press Ctrl+C to stop it. Any saved changes will be immediately reloaded.

Contents