hgh/README.md
2024-01-09 20:38:28 +01:00

2 KiB
Raw Blame History

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

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'