Skip to content

Prettier config for Hugo for formatting HTML templates, Markdown, JSON, TOML and YAML

License

Notifications You must be signed in to change notification settings

hugomods/prettier-config

Repository files navigation

HugoMods Prettier Config

This is a Prettier config for Hugo to format HTML templates, Markdown files, data files, i18n files and so on.

License Version Downloads

Installation

npm i -D @hugomods/prettier-config

Configuration

Configure the following settings on package.json.

{
  "prettier": "@hugomods/prettier-config",
  "scripts": {
    "lint:prettier": "prettier **/*.html i18n/* data/* **/*.md --check",
    "lint:prettier:fix": "prettier **/*.html i18n/* data/* **/*.md -w",
  }
}

Tweak **/*.html i18n/* data/* **/*.md to match files that need to formated.

Scripts

Check If Files Is Formatted Correctly

npm run lint:prettier

Format Files In Place

npm run lint:prettier:fix

GitHub Actions

To check if files are formatted correctly via GitHub Actions, you can create a workflow as follows, takes .github/workflows/lint.yml as an example.

name: lint

on:
  push:

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - run: npm run lint:prettier

About

Prettier config for Hugo for formatting HTML templates, Markdown, JSON, TOML and YAML

Topics

Resources

License

Stars

Watchers

Forks