HugoToJSON
A utility to produce a JSON representation of the key front matter and contents of Hugo documents. It's main intent is to produce JSON to be used by Lunr (and Lunr-like packages) to support search on a static Hugo site. It's designed to be a fast and modern alternative to the now unsupported hugo_lunr Node tool.
Pull requests are welcome. A list of goals and work to be done is available in ToDo.txt
.
It currently supports .md
files and both YAML and TOML front matter.
Using
hugo_to_json HUGO_CONTENT_DIRECTORY -o OUTPUT_LOCATION
Example usage is shown below.
hugo_to_json example/blog/content -o example/blog/static/index.json
Defaults to ./content
for the content directory and stdout for the index output.
Fetching the Latest Version
If you want to use the latest version of this tool as part of a CI build process the following script should work.
#!/usr/bin/env bash
# Based on
#https://blog.markvincze.com/download-artifacts-from-a-latest-github-release-in-sh-and-powershell/
LATEST_RELEASE=
# The releases are returned in the format {"id":3622206,"tag_name":"hello-1.0.0.11",...}, we have to extract the tag_name.
LATEST_VERSION=
ARTIFACT_URL="https://github.com/arranf/HugoToJSON/releases/download/ /hugo_to_json"
INSTALL_DIRECTORY="."
INSTALL_NAME="hugo_to_json"
DOWNLOAD_FILE=" /"
if ; then
code=
elif ; then
code=
else
fi
if [; then
fi