adds new post
This commit is contained in:
parent
aa84a07286
commit
70b0f5aebb
2 changed files with 59 additions and 14 deletions
Before Width: | Height: | Size: 109 KiB After Width: | Height: | Size: 109 KiB |
|
@ -2,24 +2,23 @@
|
||||||
title = "My current website setup"
|
title = "My current website setup"
|
||||||
summary = """This is how I install hugo nowadays. Although that routine might
|
summary = """This is how I install hugo nowadays. Although that routine might
|
||||||
change anytime."""
|
change anytime."""
|
||||||
date = "2023-01-24T00:16:14+0100"
|
date = "2023-01-24T22:36:25+0100"
|
||||||
#lastmod = ""
|
#lastmod = ""
|
||||||
categories = ["computerstuff"]
|
categories = ["computerstuff"]
|
||||||
tags = ["linux", "gohugo", "reminders"]
|
tags = ["linux", "gohugo", "reminders"]
|
||||||
|
|
||||||
draft = true
|
|
||||||
|
|
||||||
+++
|
+++
|
||||||
|
|
||||||
I'll do a quick go-through of my actual website's installation procedure.
|
Since I started writing down notes about my website-setup some of the
|
||||||
The website itself is hosted without my personal server---I'm using
|
infrastructure changed. In the meantime I moved away from Github and host
|
||||||
Cloudflare for this to work. The content is saved in a Githubrepository
|
my personal Gitea instance on my server. Some of the notes have been
|
||||||
which gets then fetched from Cloudflare. After half a minute the website
|
re-written, but I could have forgotten something---so take the following
|
||||||
is published and the website cache on Cloudflare gets cleared automatically
|
information with a grain of salt maybe. Prepare to adopt to your needs.
|
||||||
when I push new changes to the repository.
|
|
||||||
|
|
||||||
## Install hugo from source
|
## Install hugo from source
|
||||||
|
|
||||||
|
This is done on your computer.
|
||||||
|
|
||||||
### Requirements
|
### Requirements
|
||||||
|
|
||||||
- Install Git
|
- Install Git
|
||||||
|
@ -58,6 +57,8 @@ when I push new changes to the repository.
|
||||||
|
|
||||||
### Install hugo
|
### Install hugo
|
||||||
|
|
||||||
|
We are still on our computer.
|
||||||
|
|
||||||
~~~console
|
~~~console
|
||||||
$ go install -tags extended github.com/gohugoio/hugo@latest
|
$ 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
|
Start your server using `hugo server` and the theme will be downloaded
|
||||||
automatically.
|
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/`.
|
`hugo site new...`). Copy the config files from the theme into `config/_default/`.
|
||||||
|
|
||||||
{{< alert >}}
|
{{< alert >}}
|
||||||
|
@ -158,12 +159,14 @@ appropriately or make it use the values from your config.
|
||||||
|
|
||||||
Source: <https://gist.github.com/lpar/7ded35d8f52fef7490a5be92e6cd6937>
|
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
|
### Requirements
|
||||||
|
|
||||||
- A **Cloudflare website** (not pages, well---yes, but a website that uses one
|
- A **Cloudflare website** (not pages)
|
||||||
of your pages)
|
|
||||||
- An API token on Cloudflare to let git clear your website's cache (see below)
|
- An API token on Cloudflare to let git clear your website's cache (see below)
|
||||||
|
|
||||||
### Cloudflare setup
|
### Cloudflare setup
|
||||||
|
@ -230,4 +233,46 @@ Don't forget to make this script executable:
|
||||||
$ chmod +x .git/hooks/pre-push
|
$ 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.
|
||||||
|
|
Loading…
Add table
Reference in a new issue