From df1a0097dbc2536c9f7acac90699394831839a9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominique=20M=C3=BCller?= Date: Sun, 12 Aug 2018 16:07:52 +0200 Subject: [PATCH] docs(hugo): Add section on how to use the hugo binary (#6) - Add section how to use the hugo binary - Add note on updating .gitignore file --- README.md | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bb5d969..986b93e 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,8 @@ allows for the hugo version to be configured someplace else, e.g. in a `otherDep ### Configure binary path (optional) -The `--destination` CLI parameter can be used to define the folder into which the Hugo binary will be placed. For example: +The `--destination` CLI parameter can be used to define the folder into which the Hugo binary will be placed. This parameter is optional, +the default destination path is `bin/hugo`. For example: ``` json { @@ -84,7 +85,35 @@ The `--destination` CLI parameter can be used to define the folder into which th } ``` -> This parameter is optional, the default destination path is `bin/hugo`. +> Don't forget to add the destination path to your `.gitignore` file! + +


+ +## Using the Hugo binary + +Once fetched, the hugo binary can be used directly from your favourite command line. For example: + +``` bash +bin/hugo/hugo.exe --config=hugo.config.json +``` + +Alternatively, one might also want to integrate Hugo in a NodeJS build script, or a NodeJS-based build tool such as +**[Gulp](https://gulpjs.com/)**. You can execute the Hugo binary using the `spawn` command; for example: + +``` javascript +const path = require( 'path' ); +const spawn = require( 'child_process' ).spawn; + +// Use Hugo +spawn( path.resolve( process.cwd(), 'bin', 'hugo', 'hugo' ), [ + `--config=hugo.config.json` +], { + stdio: 'inherit' +} ) + .on( 'close', () => { + // Callback + } ); +```