theNewDynamic / jamstack.nyc

2 stars 2 forks source link
internal

The New Dynamic Hugo Starter

Test. This is a starter repo for The New Dynamic's web projects. Do with as you wish, but keep in mind that everything here is designed for our internal workflow.

We use a Changelog on all of our projects. Please see that file for updates.

Quickstart

note this quickstart is for established projects; not the starter.

git clone --recurse-submodules https://github.com/theNewDynamic/yourprojectname.git yourprojectname
yarn install
yarn start

Deployment

  1. Before deploying, run yarn deploy (or hugo --gc if you're not generating fonts or JS) to generate a minified, purged CSS file.
  2. Check the resources folder into your repository.

tools

Fonts

When possible, we use Kyle Mathews' Typefaces so that we can server our font files locally. Just add the typeface to assets/index.js and run the webpack build, as above (yarn build). This will generate the font files into the static/fonts directory (which Hugo will automatically copy into the public directory) and generate a fonts CSS file, which then Hugo will minify and fingerprint into your head.

CSS

We use TailwindCSS and several PostCSS plugins to generate CSS. Most of your CSS will be utility classes in your templates. Hugo will not rebuild your CSS file unless the file itself is changed. In a TailwindCSS context, most of your work occurs in templates, not in the CSS file. To make development easier, we've created a separate PostCSS config file without PurgeCSS. However, this means you must run yarn deploy (as outline below) for you push your changes.

Testing

Download htmltest to your local environment, build your site locall (to the public folder), and run htmltest in your site's path. If you need to change any parameters of the test, you'll find them in .htmltest.yml

Hugo Asset Pipline

This set up utilizes Parcel for Javascript and open source font processing, Hugo Pipes + PostCSS for CSS processing, and npm-run-all to run Parcel and Hugo in parallel (see note below). We use the Yarn package manager, but you can use NPM if you like. This configuration is built around the assumption that JS/Fonts are processed in development, not production, though it would take minimal effort to do so.

JS

CSS

CSS via Parcel

Fonts

Images

Other Notes

To Use

git clone https://github.com/theNewDynamic/hugo-starter.git yourprojectname

cd yourprojectname

rm -rf .git

git init

git add .

git commit -m "initial commit"

git remote add origin https://github.com/theNewDynamic/YOURPROJECTNAME.git

git push -u origin master

git submodule add https://github.com/theNewDynamic/hugo-layout_module-base-2019.git components/layout_module-base

repeat for additional modules

Add theme component to config.toml:

_Note. Hugo uses the "themes" directory by default. We've renamed that to layout_modules._