dirkolbrich / hugo-tailwindcss-starter-theme

Starter files for a Hugo theme with Tailwindcss
MIT License
400 stars 55 forks source link
hugo starter-template tailwindcss theme-development

Hugo Starter Theme with Tailwind CSS

Starter files for a Hugo theme with Tailwind CSS.

Live long and code.

What this theme is NOT

This theme is a starter setup theme to aid in developing Hugo themes using the Tailwind CSS framework. It is not a standalone theme ready to use.

Prerequisites

Make sure to install postcss-cli and autoprefixer globally in your environment, as Hugo Pipe’s PostCSS requires it. This is mentioned in the Hugo Docs.

npm install -g postcss-cli
npm install -g autoprefixer

Make sure to use a minimum Hugo version of v0.120.0 and above.

Basic usage to develop a separate Theme repo

git clone https://github.com/dirkolbrich/hugo-tailwindcss-starter-theme new-theme-name
cd new-theme-name
rm -rf .git
git init
npm install
# in hugo.toml
theme = "new-theme-name" # your new theme name here
hugo server -s exampleSite --themesDir=../.. --disableFastRender

Usage directly within a Hugo repo as a theme package

hugo new site new-site
cd new-site/themes
git clone https://github.com/dirkolbrich/hugo-tailwindcss-starter-theme new-theme-name
cd new-theme-name
rm -rf .git
npm install
# in hugo.toml
theme = "new-theme-name" # your new theme name here
cd new-site
hugo server --disableFastRender

Your content should go into new-site/content, the development of the site layout is done within new-site/themes/new-theme-name/layout.

Helpers

Included are some helpers for the development phase (not visible in production):

If you don't need any of these helpers anymore, just delete the {{- partial "dev/dev-tools.html" . -}} line from /layouts/_default/baseof.html.

Reference