|
|
|
@ -2,24 +2,23 @@
|
|
|
|
|
title = "My current website setup"
|
|
|
|
|
summary = """This is how I install hugo nowadays. Although that routine might
|
|
|
|
|
change anytime."""
|
|
|
|
|
date = "2023-01-24T00:16:14+0100"
|
|
|
|
|
date = "2023-01-24T22:36:25+0100"
|
|
|
|
|
#lastmod = ""
|
|
|
|
|
categories = ["computerstuff"]
|
|
|
|
|
tags = ["linux", "gohugo", "reminders"]
|
|
|
|
|
|
|
|
|
|
draft = true
|
|
|
|
|
|
|
|
|
|
+++
|
|
|
|
|
|
|
|
|
|
I'll do a quick go-through of my actual website's installation procedure.
|
|
|
|
|
The website itself is hosted without my personal server---I'm using
|
|
|
|
|
Cloudflare for this to work. The content is saved in a Githubrepository
|
|
|
|
|
which gets then fetched from Cloudflare. After half a minute the website
|
|
|
|
|
is published and the website cache on Cloudflare gets cleared automatically
|
|
|
|
|
when I push new changes to the repository.
|
|
|
|
|
Since I started writing down notes about my website-setup some of the
|
|
|
|
|
infrastructure changed. In the meantime I moved away from Github and host
|
|
|
|
|
my personal Gitea instance on my server. Some of the notes have been
|
|
|
|
|
re-written, but I could have forgotten something---so take the following
|
|
|
|
|
information with a grain of salt maybe. Prepare to adopt to your needs.
|
|
|
|
|
|
|
|
|
|
## Install hugo from source
|
|
|
|
|
|
|
|
|
|
This is done on your computer.
|
|
|
|
|
|
|
|
|
|
### Requirements
|
|
|
|
|
|
|
|
|
|
- Install Git
|
|
|
|
@ -58,6 +57,8 @@ when I push new changes to the repository.
|
|
|
|
|
|
|
|
|
|
### Install hugo
|
|
|
|
|
|
|
|
|
|
We are still on our computer.
|
|
|
|
|
|
|
|
|
|
~~~console
|
|
|
|
|
$ go install -tags extended github.com/gohugoio/hugo@latest
|
|
|
|
|
~~~
|
|
|
|
@ -92,7 +93,7 @@ path = "github.com/jpanther/congo/v2"
|
|
|
|
|
Start your server using `hugo server` and the theme will be downloaded
|
|
|
|
|
automatically.
|
|
|
|
|
|
|
|
|
|
Remove the file `config.toml` from your website root directory (generaded by
|
|
|
|
|
Remove the file `config.toml` from your website root directory (generated by
|
|
|
|
|
`hugo site new...`). Copy the config files from the theme into `config/_default/`.
|
|
|
|
|
|
|
|
|
|
{{< alert >}}
|
|
|
|
@ -158,12 +159,14 @@ appropriately or make it use the values from your config.
|
|
|
|
|
|
|
|
|
|
Source: <https://gist.github.com/lpar/7ded35d8f52fef7490a5be92e6cd6937>
|
|
|
|
|
|
|
|
|
|
## Auto-clear cache on git push
|
|
|
|
|
## Auto-clear Cloudflare cache on git push
|
|
|
|
|
|
|
|
|
|
If we use Cloudflare, we want the cache to be cleared. We are still on
|
|
|
|
|
our computer.
|
|
|
|
|
|
|
|
|
|
### Requirements
|
|
|
|
|
|
|
|
|
|
- A **Cloudflare website** (not pages, well---yes, but a website that uses one
|
|
|
|
|
of your pages)
|
|
|
|
|
- A **Cloudflare website** (not pages)
|
|
|
|
|
- An API token on Cloudflare to let git clear your website's cache (see below)
|
|
|
|
|
|
|
|
|
|
### Cloudflare setup
|
|
|
|
@ -230,4 +233,46 @@ Don't forget to make this script executable:
|
|
|
|
|
$ chmod +x .git/hooks/pre-push
|
|
|
|
|
~~~
|
|
|
|
|
|
|
|
|
|
Finished.
|
|
|
|
|
## Publish the website
|
|
|
|
|
|
|
|
|
|
Since the end of December 2022 I use my own git hosting service on my
|
|
|
|
|
own server. I used Github before that.
|
|
|
|
|
|
|
|
|
|
If you save your website repository on Github: create a Cloudflare page
|
|
|
|
|
and you are probably good to go. Don't forget to enable that page in
|
|
|
|
|
the website settings at Cloudflare.
|
|
|
|
|
|
|
|
|
|
Okay, since I stopped using Github I have to publish my git repository
|
|
|
|
|
somewhere to the public root of my webserver. That is done via a
|
|
|
|
|
post-receive hook on the git servers repository.
|
|
|
|
|
|
|
|
|
|
It's actually the file `website.git/hook/post-receive.d/publish`:
|
|
|
|
|
|
|
|
|
|
~~~bash
|
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
|
|
# change these to your needs...
|
|
|
|
|
GIT_REPO=/var/.../website.git
|
|
|
|
|
WORKING_DIR=${HOME}/website-working
|
|
|
|
|
PUBLIC_WWW=/var/www/html
|
|
|
|
|
BACKUP_WWW=/var/www/backup
|
|
|
|
|
MY_DOMAIN=website.com
|
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
rm -rf ${WORKING_DIR}
|
|
|
|
|
rsync -aqz ${PUBLIC_WWW}/ ${BACKUP_WWW}
|
|
|
|
|
trap "echo 'A problem occured. Reverting to backup.'; rsync -aqz --del ${BACKUP_WWW}/ ${PUBLIC_WWW}; rm -rf ${WORKING_DIR}" EXIT
|
|
|
|
|
|
|
|
|
|
git clone ${GIT_REPO} ${WORKING_DIR}
|
|
|
|
|
rm -rf ${PUBLIC_WWW}/*
|
|
|
|
|
/home/git/go/bin/hugo --gc --minify --cleanDestinationDir -s ${WORKING_DIR} -d ${PUBLIC_WWW}
|
|
|
|
|
rm -rf ${WORKING_DIR}
|
|
|
|
|
trap - exit
|
|
|
|
|
~~~
|
|
|
|
|
|
|
|
|
|
If you use Gitea, those repositories are per default in
|
|
|
|
|
`/var/lib/gitea/data/gitea-repositories/`...
|
|
|
|
|
|
|
|
|
|
That is it, basically.
|
|
|
|
|
|