No description
Find a file
2024-01-09 21:57:45 +01:00
templates init 2024-01-09 20:05:01 +01:00
.gitignore init 2024-01-09 20:05:01 +01:00
hgh.json init 2024-01-09 20:05:01 +01:00
hgh.py remove debug output 2024-01-09 21:25:59 +01:00
README.md link to blog post 2024-01-09 21:57:45 +01:00

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 copy hgh.json into this directory.
  • Create ~/.cache/hgh/ directory.
  • Move hgh.py file and templates directory to anywhere on your system.
  • In hgh.json config 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 --printconfig or hgh.py --site xyz -cdw for 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'