20 Jan 2018
Create a blog using static site generator Hugo
This blog is (edit Hugo, a static site generator (a nice post about this technique and its difference to dynamic pages by David Walsh) written in Go, and is hosted ob uberspace.
: was) created usingGet Hugo running on your local machine
- get the binaries from https://github.com/gohugoio/hugo/releases
- create a new site using
hugo new site YOUR-SITENAME
- search for a theme on https://themes.gohugo.io/, clone it, and copy
it into the
themes
folder [create the folder if it is not available] - edit the
config.toml
and change the fields according to your information - run
hugo new post/YOUR-NEW-POST.md
- run
hugo server
(orhugo server -D
when your post is still a draft -> check in the toml header of the file) to visit your site at localhost and test/adapt your post and theme
Version control your blog with git
Local
- in the root directory of the blog run
git init
- add all files using
git add .
andgit commit -m "initial commit"
- optional: create a
.gitignore
file and write all names of these files and folders you do not want to upload to the server (e.g. automatic backup files) - Create a bare git repository that can be send to the server. To do
this, leave the blog root directory (
cd ..
) and rungit clone --bare YOUR-LOCAL-GIT-BLOG-FOLDER YOUR-SERVER-GIT-BLOG-FOLDER.git
- copy the newly created bare repository to your server (e.g. using
scp
) - move again into your local blog folder and add the remote address to
your blog using
git remote add origin SERVERADRESS:REPOSITORY-FOLDER
Server
- ssh into your server
cd
into the hooks folder of your blog directory- using your favorite editor (what is without doubt emacs) create a
file named
post-receive
and add the following content:
#!/bin/bash -l GIT_REPO=$HOME/your-blog.git TMP_GIT_CLONE=$HOME/tmp/git/your-blog.git PUBLIC_WWW=/var/www/virtual/$USER/html git clone $GIT_REPO $TMP_GIT_CLONE hugo $TMP_GIT_CLONE cp -r $TMP_GIT_CLONE/public/ $PUBLIC_WWW rm -Rf $TMP_GIT_CLONE exit
- make the hook file executable
chmod u=rwx post-receive
- test whether everything is working by manually executing the hook
file
.post-receive
- when everything works leave the server and enjoy writing of your site locally. After you pushed your changes to the server the site will be generated automatically
Links
The information above was collected from these sources:
Hugo:
- https://gohugo.io/categories/getting-started
- https://code.tutsplus.com/tutorials/make-creating-websites-fun-again-with-hugo-the-static-website-generator-written-in-go--cms-27319
- https://github.com/humboldtux/startbootstrap-clean-blog
- https://themes.gohugo.io/theme/strata/post/migrate-from-jekyll/
Uberspace [note that the instructions are for jekyll – and in German.]:
- http://www.wittistribune.com/jekyll-auf-uberspace-mit-git
- https://funkenstrahlen.de/blog/2015/08/02/jekyll-blog-auf-uberspace-mein-setup/
Git: