Skip to main content

An incredibly simple python script that makes working with archtypes in Hugo 0.5x much easier.

Project description

hugon

https://img.shields.io/pypi/v/hugon.svg

An incredibly simple (CLI) python script that makes working with archetypes in Hugo 0.5x much easier.

Hugon Sample Run
  • Free software: MIT license

Why

  • When working with archetypes, the CLI expects us to mention the exact file name we want to create, instead of converting a provided string into a valid file name.

  • Inability to create a sequence of files (Example, creating an FAQ’s Markdown Page with faq-1.md, faq-2.md, faq-3.md file names). We’re expected to enter them manually each time.

  • When working with projects that require us to create multiple markdown files, we can’t add more than the “title” field to our markdown files.

Features

  • Enter a string with as many special characters you wish to enter, the script will convert it into a suitable file name. Eg: “This new blog post I want to write!” in the command line would convert into “this-new-blog-post-i-want-to-write.md”.

  • Enter the archetype you wish to enter, the script will check if the archetype exists. If it doesn’t exist, Hugo CLI will prompt you with an error.

  • Create multiple markdown files and automatically populate the variables + content fields from a local CSV! (YAML format front matter only)

  • Let’s you use a custom prefix CLI if you’re using any other CLI that handshakes with hugo. Only changes prefix that could replace the “hugo new” function

  • Enter the amount of files you want to create in sequence, the script will create everything.

  • Colour codes the output (ft. colorama) for you to differentiate between outputs.

  • Let’s you use a custom separator if you’d like something apart from ‘-‘ hyphens in your file name.

Requirements

  • Python 3.x

  • Hugo CLI (Tested on 0.59.1)

How To Use (Normal)

  1. pip install hugon

  2. cd Into your hugo initialized folder.

  3. run the command ‘hugon -name “N3w F!le” -arch “default” -sequence “5”

Syntax (Normal)

Command

Description

Required?

Example

Converts Into

-archetype

Define Archetype Name (without file extension). The Archetype file of this name should be present in the archetype folder. (Name is automatically converted to lowercase)

Yes

Default

default

-name

Filename you’d want to set. Can contain spaces, numbers, special characters, all which will be stripped (and converted to lowercase) to create a seamless file name to send to Hugo CLI.

Yes

FILE NAM3 Ex@mple

file-nam3-exmple.md

-sequence

Lets you create multiple files with a ‘sequence’ as a postfix. Helpful if you’re working with FAQ’s, or other pages where file name doesn’t necessarily matter. Value has to be more than 1, with sequence kicking off skipping 0.

No

5

file-nam3-exmple1.md

file-nam3-exmple2.md

file-nam3-exmple3.md

file-nam3-exmple4.md

file-nam3-exmple5.md

-separator

Lets you define a custom separator that’s not “-” a hyphen.

No

_

file_nam3_example.md

-prefix

Use another command instead of “hugo new”.

No

npm run customdev

npm run customdev default/file_nam3_example.md

How To Use (Generate From CSV)

  1. Create a ‘data.csv’ file in the root of your hugo site.

  2. Enter all the required variable fields (along with the required compulsory fields) as columns on your first row, and populate to your hearts content.

  3. Run command ‘hugon -csv yes’

  4. If you’d like to overwrite your files without being prompted (Risky) just pass ‘-overwrite true’ as an argument.

Syntax (CSV)

Hugon Sample Run | CSV

Warning: Files would be modified the moment they’re made. Mistakes cannot be undone.

Column Name

Required

Purpose

archetype

Yes

States archetype of post to be made.

content

No

Lets you add matter to the “content” section of your markdown file.

filename

No

Lets you specify another filename if you don’t want to use a ‘sluggified’ title. Please ensure you don’t add ‘.md’ to the filename and your file name has the proper separators.

title

Yes

Title field/filename.

prefix

No

Any custom build command you’d like to specify.

separator

No

Any custom separator (if you’re generating from title column) apart from default ‘-’

  • Looking to add tags/taxonomies? Separate your values in the column with a ^;

  • Looking to values to your YAML without quotation marks? (Eg: true/false values) Prepend your value with ^

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.1.4 (2019-12-13)

  • Fixed bug that stopped you from specifying a sequence.

  • Fixed content replacement (CSV) issue that duplicated the section instead of replacing it.

  • Pushed non-hugo CLI messages to colorama function for easy readibility.

  • Added pretty ‘horizontal line breaks’ after any code is executed. (Resizes the next output to your existing terminal size)

  • Other bug fixes and optimizations

0.1.1 (2019-12-13)

  • Added CSV support for dynamic YAML markdown file generation.

0.1.0 (2019-12-06)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hugon-0.1.5.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

hugon-0.1.5-py2.py3-none-any.whl (8.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file hugon-0.1.5.tar.gz.

File metadata

  • Download URL: hugon-0.1.5.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.1

File hashes

Hashes for hugon-0.1.5.tar.gz
Algorithm Hash digest
SHA256 8d525978c2d699e22fd6da9f570d8c8966e34e3b2ce616eb7ea44193d0c2e252
MD5 2a9e88ad3625ba8da9d085ac93955bd6
BLAKE2b-256 b6bfd0fa12a2433b051f18969cf99935f9400ffcb21c47756795a98abc5f6772

See more details on using hashes here.

File details

Details for the file hugon-0.1.5-py2.py3-none-any.whl.

File metadata

  • Download URL: hugon-0.1.5-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.1

File hashes

Hashes for hugon-0.1.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ee1268216e8ae0751f08784a4bfdc2f6ea5ba0f4716aafab73b171ce0b00ad75
MD5 3e936d684c8715c74899d9a5c2bb8c38
BLAKE2b-256 4ef61680139b2b68fee994ef6142cc4558aa3b2e87b279acfd6e02d0740d08d7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page