ngh - you want to know this command

Easy deployment of Angular projects to GitHub Pages

Posted by Krzysztof Zbiciński on 2017-04-16.

Back in the days there was a command in the Angular CLI named ng ghpages. It was intended to provide a trival way of publishing the application generated with ng. It was building the project, grabbing the contents of the dist directory and pushing them to the gh-pages branch of the repository. Then, the application was available online at <USERNAME>.github.io/<REPOSITORY NAME>.

Because of unknown reasons (ok, not so uknown) it got removed from the Angular CLI:

@gkucmierz there were many reported issues with this command, so rather than ship the CLI with the issues it was decided to remove it, especially with some viable community alternatives.

The void was quickly filled with new tools that were performing the same task. One that is especially worth recommending is angular-cli-ghpages. I use it in my Go home, JS project and it works flawlessly. You can check it out yourself by visiting http://zbic.in/go-home-js.

What I would consider a good practice is creating an npm script that calls ngh with all required parameters. You can go through all of the options yourself, to see what opportunities it gives. As a quick tl;dr example, a fragment of my package.json looks as follows:

package.json
1
2
3
4
5
6
{
"scripts": {
"ghpages": "ngh --no-silent --name=\"Krzysztof Zbiciński\" --email=\"<MY GITHUB EMAIL>\"",
},
//...
}

Photo by SpaceX on Unsplash.


Comments: