| templates | ||
| .gitignore | ||
| hgh.json | ||
| hgh.py | ||
| README.md | ||
hgh – Hugo Helper
A Python script to do magic when working with Hugo websites.
It was created for my websites. So this is not for general purpose. If it works for you, great. If not, fine.
Most things should work for others without change, but commands like --create-pagebundle probably need to be adapted for everyone else.
Ich nix English. Habs versucht. :P
Eine ausführliche Beschreibung, was ich mit diesem Script mache, gibt es in meinem Blog, siehe hier.
Dependencies
Python
argparse, os, time, re, subprocess, json, sys, datetime, pytz, jinja2, tempfile, glob, pathlib
Tools
- find (Should be already installed on most Linux systems)
- ripgrep (binary is rg)
- fzf (Fuzzy Find for some commands)
- hugo
- rsync
- yq (only for --create-tags-categories-caches)
- VSCode (optional and only used to open a new created page bundle)
Installation
- Install dependencies (Python modules and tools).
- Create
~/.config/hgh/and copyhgh.jsoninto this directory. - Create
~/.cache/hgh/directory. - Move
hgh.pyfile andtemplatesdirectory to anywhere on your system. - In
hgh.jsonconfig file adapt at least: (Do not use~for paths within the config file.)- "settings" -> "template_path"
- "settings" -> "shell" (default: /bin/bash)
- "settings" -> "bin_editor" (default: micro)
- "sites" -> everything…
- run
hgh.py --printconfigorhgh.py --site xyz -cdwfor testing..
Find tags and/or categories
To get a list of tags and categories used within a website, run from time to time:
hgh.py --site xyz --create-tags-categories-caches
This creates two cache files with counts of tags and categories. See sites -> "list_tag" and sites -> "list_categories" in hgh.json for the file paths.
Create Page Bundles
If you want to use creation of page bundles with --create-pagebundle, please adapt paths and logic in if args.create_pagebundle: of hgh.py. Without changes it works only for Natenoms blog.
Misc
Tipps
Um nicht dauernd hgh.py --site blog eingeben zu müssen, kann man einen Alias in der Shell einrichten und in die .bashrc eintragen:
alias hgb='hgh.py --site blog'