added deployment guide 2

This commit is contained in:
Devoalda 2022-08-25 22:55:15 +08:00
parent 99407a88cf
commit 8197a7da63
2 changed files with 131 additions and 0 deletions

124
content/en/posts/Hugo.md Normal file
View File

@ -0,0 +1,124 @@
---
author: "Devoalda"
authorEmoji: 🐺
title: "Hugo CI/CD Deployment with Gitlab"
description: Hugo CI/CD Deployment with Gitlab
date: 2022-08-25T18:15:01+08:00
draft: false
hideToc: false
enableToc: true
enableTocContent: true
tocPosition: inner
tocLevels: ["h1", "h2", "h3", "h4"]
image: images/postImages/hugo.svg
tags:
- gitlab
- Hugo
- program
- CI/CD
series:
- Web Development
categories:
- gitlab
- Hugo
- CI/CD
---
# 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](https://github.com/zzossig/hugo-theme-zzo)
```shell
git clone --recurse-submodules https://gitlab.com/devoalda/devoalda.gitlab.io.git
```
# Hugo
This command will run a server on localhost:1313
```shell
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](https://gohugo.io/commands/hugo/)
## Theme
[This](https://github.com/zzossig/hugo-theme-zzo) is the theme I'm using currently
[Here](https://zzo-docs.vercel.app/) are more themes to checkout
### Configuration
This [Documentation](https://zzo-docs.vercel.app/zzo/configuration/configfiles/) 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
{{< codes java javascript >}}
{{< code >}}
```java
System.out.println('Hello World!');
```
{{< /code >}}
{{< code >}}
```javascript
console.log('Hello World!');
```
{{< /code >}}
{{< /codes >}}
#### Image
{{< img src="/images/header/background.jpg" title="Sample Image" caption="Image with title, caption, alt, ..." alt="image alt" width="700px" position="center" >}}
#### Tabs
{{< tabs Windows MacOS Ubuntu >}}
{{< tab >}}
### Windows section
```javascript
console.log('Hello World!');
```
{{< /tab >}}
{{< tab >}}
### MacOS section
Hello world!
{{< /tab >}}
{{< tab >}}
### Ubuntu section
Great!
{{< /tab >}}
{{< /tabs >}}
# Gitlab CI/CD with Hugo
This is the gitlab's CI/CD .yml file, available through the side pane > CI/CD > Editor
```shell
# 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
```

View File

@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" stroke-width="27" aria-label="Logo" viewBox="0 0 1493 391">
<path fill="#ebb951" stroke="#fcd804" d="M1345.211 24.704l112.262 64.305a43 43 0 0 1 21.627 37.312v142.237a40 40 0 0 1-20.702 35.037l-120.886 66.584a42 42 0 0 1-41.216-.389l-106.242-61.155a57 57 0 0 1-28.564-49.4V138.71a64 64 0 0 1 31.172-54.939l98.01-58.564a54 54 0 0 1 54.54-.503z"/>
<path fill="#33ba91" stroke="#00a88a" d="M958.07 22.82l117.31 66.78a41 41 0 0 1 20.72 35.64v139.5a45 45 0 0 1-23.1 39.32L955.68 369.4a44 44 0 0 1-43.54-.41l-105.82-61.6a56 56 0 0 1-27.83-48.4V140.07a68 68 0 0 1 33.23-58.44l98.06-58.35a48 48 0 0 1 48.3-.46z"/>
<path fill="#0594cb" stroke="#0083c0" d="M575.26 20.97l117.23 68.9a40 40 0 0 1 19.73 34.27l.73 138.67a48 48 0 0 1-24.64 42.2l-115.13 64.11a45 45 0 0 1-44.53-.42l-105.83-61.6a55 55 0 0 1-27.33-47.53V136.52a63 63 0 0 1 29.87-53.59l99.3-61.4a49 49 0 0 1 50.6-.56z"/>
<path fill="#ff4088" stroke="#c9177e" d="M195.81 24.13l114.41 66.54a44 44 0 0 1 21.88 38.04v136.43a48 48 0 0 1-24.45 41.82L194.1 370.9a49 49 0 0 1-48.48-.23L41.05 310.48a53 53 0 0 1-26.56-45.93V135.08a55 55 0 0 1 26.1-46.8l102.8-63.46a51 51 0 0 1 52.42-.69z"/>
<path fill="#fff" d="M1320.72 89.15c58.79 0 106.52 47.73 106.52 106.51 0 58.8-47.73 106.52-106.52 106.52-58.78 0-106.52-47.73-106.52-106.52 0-58.78 47.74-106.51 106.52-106.51zm0 39.57c36.95 0 66.94 30 66.94 66.94a66.97 66.97 0 0 1-66.94 66.94c-36.95 0-66.94-29.99-66.94-66.94a66.97 66.97 0 0 1 66.93-66.94h.01zm-283.8 65.31c0 47.18-8.94 60.93-26.81 80.58-17.87 19.65-41.57 27.57-71.1 27.57-27 0-48.75-9.58-67.61-26.23-20.88-18.45-36.08-47.04-36.08-78.95 0-31.37 11.72-58.48 32.49-78.67 18.22-17.67 45.34-29.18 73.3-29.18 33.77 0 68.83 15.98 90.44 47.53l-31.73 26.82c-13.45-25.03-32.94-33.46-60.82-34.26-30.83-.88-64.77 28.53-62.25 67.75 1.4 21.94 11.65 59.65 60.96 66.57 25.9 3.63 55.36-24.02 55.36-39.04H944.4v-37.5h92.5V194l.02.03zm-562.6-94.65h42.29v112.17c0 17.8.49 29.33 1.47 34.61 1.69 8.48 4.81 14.37 11.17 19.5 6.37 5.13 13.8 6.59 24.84 6.59 11.2 0 14.96-1.74 20.66-6.6 5.69-4.85 9.12-9.46 10.28-16.53 1.15-7.07 3.07-18.8 3.07-35.18V99.38h42.28v108.78c0 24.86-1.07 42.43-3.21 52.69-2.14 10.27-6.08 18.93-11.82 26-5.74 7.06-13.42 12.69-23.03 16.88-9.62 4.19-22.16 6.28-37.65 6.28-18.7 0-32.87-2.28-42.52-6.85-9.66-4.57-17.3-10.5-22.9-17.8-5.61-7.3-9.3-14.95-11.08-22.96-2.58-11.86-3.88-29.38-3.88-52.55V99.38h.03zM93.91 299.92V92.7h43.35v75.48h71.92V92.7h43.48v207.22h-43.48v-90.61h-71.92v90.61z"/>
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB