Code Monkey home page Code Monkey logo

hugulp's Introduction

hugulp

hugulp is a tool to optimize the assets of a Hugo website.

The main idea is to recreate the famous Ruby on Rails Asset Pipeline, which minifies, concatenates and fingerprints the assets used in your website.

This leads to less and smaller network requests to your page, improving overall user experience.

Read this blog post and this article for additional context.

It's internally driven by Gulp.

This project Includes the following tools, tasks and workflows:

Installation

Node needs to be installed in your system.

Then just

$ npm install -g hugulp

Getting Started

hugulp requires you to create the following folders inside your hugo site:

  • assets/img
  • assets/styles
  • assets/scripts

For example

$ hugo new site website
$ cd website
$ mkdir -p assets/{img,styles,scripts}
# create content, add images, css/sass and javascript files to the corresponding folders>
$ hugulp build

It will use hugo's default config file: config.toml, but you can specify a different config via the -c, --config switch

$ hugulp build --config config.yaml

Or

$ hugulp watch --config config.yaml

Available Commands

hugulp watch

It will do the following:

  • Convert sass to css, then minify the result (works on assets/styles/*.{css,scss})
  • Compress images (works on assets/images/*.*)
  • Minify javascript files (works on assets/scripts/*.js)
  • Fingerprint the optimized assets from the previous steps
  • Invoke hugo to generate the site

hugo will be invoked like this:

$ hugo --config=config.toml -s . -d ./public --buildDrafts=true --verbose=true --baseUrl="http://localhost:3000/"
  • Change all references to the assets in your content files (index.html, etc.)
  • Watch for changes to content files or assets to reload the browser

hugulp build

It runs the same pipeline as the hugulp build command, but hugo is invoked as follows:

$ hugo --config=config.toml -s . -d ./public"

Additionally, files are not watched for changes

How to update

Whenever a new hugulp version becomes available, you can update it by running

$ npm update -g hugulp

PR

Pull Requests are welcome ๐Ÿ‘.

Share

Made by Juan B. Rodriguez, with a MIT License.

Please share the article or leave your comments.

hugulp's People

Contributors

jbrodriguez avatar jamesmcmahon avatar jaydreyer avatar mgladdish avatar stijnsymons avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.