commands: Add .gitignore "hugo new site"
authorNathaniel Peiffer <nathaniel@peiffer.com.au>
Tue, 16 Oct 2018 06:36:27 +0000 (17:36 +1100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 16 Oct 2018 06:36:27 +0000 (08:36 +0200)
commands/new_site.go

index 3e4cf4561c44e2102c6be86c9026b663b00e481f..3d62bd44c16c86fb82d9970c104919568e3074e4 100644 (file)
@@ -97,6 +97,7 @@ func (n *newSiteCmd) doNewSite(fs *hugofs.Fs, basepath string, force bool) error
        }
 
        createConfig(fs, basepath, n.configFormat)
+       createGitignore(fs, basepath)
 
        // Create a default archetype file.
        helpers.SafeWriteToDisk(filepath.Join(archeTypePath, "default.md"),
@@ -141,6 +142,14 @@ func createConfig(fs *hugofs.Fs, inpath string, kind string) (err error) {
        return helpers.WriteToDisk(filepath.Join(inpath, "config."+kind), &buf, fs.Source)
 }
 
+func createGitignore(fs *hugofs.Fs, inpath string) (err error) {
+       var gitignore bytes.Buffer
+
+       gitignore.WriteString("public/")
+
+       return helpers.WriteToDisk(filepath.Join(inpath, ".gitignore"), &gitignore, fs.Source)
+}
+
 func nextStepsText() string {
        var nextStepsText bytes.Buffer