Creating the blog
Building the web⌗
To build the web we have chosen to use Hugo as a generator of static sites, so that we can automate the maintenance and deployment, which we will perform through Travis and GitHub pages.
Hugo⌗
Hugo is a static site generator written in Go.
We have used the instructions available in the [official documentation] (https://gohugo.io/getting-started/installing/) for the installation and initial configuration.
The theme chosen as the base is [“Terminal”] (https://themes.gohugo.io/hugo-theme-terminal/), over which we will make all necessary modifications.
To protect write ups for active challenges, we will use [Hugo Encrypt] (https://github.com/Izumiko/hugo-encrypt) to protect the posts with the challenge flag, so that only people who have already solved it can access their writeup.
Continuous deployment⌗
We will create two repositories in GitHub following [these instructions] (https://gohugo.io/hosting-and-deployment/hosting-on-github/), so we will end with two repositories, one with the source code of the web, which we must keep private, and the second with the result of processing the web with Hugo, whose files will be served by GitHub Pages.
We connect the first GitHub account (our main account) with Travis, and add the password of our second account as a protected environment variable in Travis, so that we can use it in the scripts to push the second repository, from which the GitHub Pages files will be served.
Once the two repositories are configured, we will add the following three files to the first repository:
.travis.yml
---
git:
submodules: false
before_install:
- chmod +x init-submodule.sh
- ./init-submodule.sh
install:
- curl -LO https://github.com/gohugoio/hugo/releases/download/v0.62.2/hugo_0.62.2_Linux-64bit.deb
- sudo dpkg -i hugo_0.62.2_Linux-64bit.deb
script:
- hugo
- docker run -it --rm -v `pwd`/public:/data/site chaosbunker/hugo-encrypt hugo-encrypt -sitePath /data/site
deploy:
- provider: script
script: chmod +x ./deploy.sh && ./deploy.sh
skip_cleanup: true
on:
branch: master
init-submodule.sh
cd public
if [ -n "$GITHUB_AUTH_SECRET" ]
then
touch ~/.git-credentials
chmod 0600 ~/.git-credentials
echo $GITHUB_AUTH_SECRET > ~/.git-credentials
cat ~/.git-credentials
git config credential.helper store
git config user.email "rmartinsanta-bot@users.noreply.github.com"
git config user.name "rmartinsanta-bot"
fi
cd ..
git submodule update --init --recursive
deploy.sh
#!/bin/bash
cd public
if [ -n "$GITHUB_AUTH_SECRET" ]
then
touch ~/.git-credentials
chmod 0600 ~/.git-credentials
echo $GITHUB_AUTH_SECRET > ~/.git-credentials
echo "Credentials"
cat ~/.git-credentials
git config credential.helper store
git config user.email "rmartinsanta-bot@users.noreply.github.com"
git config user.name "rmartinsanta-bot"
fi
git add .
git commit -m "Update site"
git push --force https://rmartinsanta-bot:$BOT_PASSWORD@github.com/rmartinsanta/raulmart.in.git HEAD:master
In addition, we will add the following line to the config.toml
file under the[params]
section:
[params]
DefaultContentLanguage = "en"
Create the i18n
folder at the web root, and add inside the internationalization files that hugo_encryptor
needs (they will depend on the blog languages, I will add two, one for Spanish and one for English).
index.en.md⌗
[protectedByPassword]
other = "The following content is protected. Use the root flag for machine writeups, or the challenge flag for challenge writeups."
[enterPassword]
other = "Please enter the password."
[decrypt]
other = "Show content"
[wrongPassword]
other = "Incorrect Password"
index.es.md⌗
[protectedByPassword]
other = "El contenido de este post está protegido. Utiliza la flag de root para posts sobre máquinas, o la flag del reto para posts sobre retos."
[enterPassword]
other = "Porfavor, introduzca la contraseña"
[decrypt]
other = "Acceder"
[wrongPassword]
other = "Contraseña errónea"
If I have not forgotten anything you should have the web working :D