This page looks best with JavaScript enabled

Hugo CI/CD Deployment with Gitlab

 ·  ☕ 2 min read  ·  🐺 Devoalda

Introduction

Hugo is an open-source static website generator written in GO, I’m using it as a website generator for this particular website.

This is a guide on how to deploy a static website with hugo and gitlab

Purpose of this guide

This documentation serves as a guide for me to look back on when I need to deploy websites using Gitlab’s CI/CD or Hugo and alternatives.

You will be able to use this guide as reference for deploying your own websites!

Cloning the repository

This will clone the repository of the website with the theme

1
git clone --recurse-submodules https://gitlab.com/devoalda/devoalda.gitlab.io.git

Hugo

This command will run a server on localhost:1313

1
hugo server

Running hugo alone will Build the website and output the statistics and build time with any errors that might come up during the build

For more detailed hugo commands please read their documentation

Theme

This is the theme I’m using currently
Here are more themes to checkout

Configuration

This Documentation contains the configuration file structure and the different configuration files

Shortcodes

[Here] are the documentation for shortcodes, those listed below are just some I’ll use more frequently

Code Shortcode

1
System.out.println('Hello World!');
1
console.log('Hello World!');

Image

image alt
Sample Image: Image with title, caption, alt, ...

Tabs

Windows section

1
console.log('Hello World!');

MacOS section

Hello world!

Ubuntu section

Great!

Gitlab CI/CD with Hugo

This is the gitlab’s CI/CD .yml file, available through the side pane > CI/CD > Editor

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# This file is a template, and might need editing before it works on your project.
---
# All available Hugo versions are listed here:
# https://gitlab.com/pages/hugo/container_registry
image: registry.gitlab.com/pages/hugo:latest

variables:
	GIT_SUBMODULE_STRATEGY: recursive

test:
	script:
		- hugo
	except:
		- master

pages:
	script:
		- hugo
	artifacts:
		paths:
		- public
	only:
		- master
Share on

Devoalda
WRITTEN BY
Devoalda
Technophile