Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-10-13 09:12:06 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-10-16 16:22:03 +0300
commit9185e11effa682ea1ef7dc98f2943743671023a6 (patch)
treef89d4138ddffd163a2afcd814ed2c26d3c66c4c9 /commands
parent168a3aab4622786ccd0943137fce3912707f2a46 (diff)
Reimplement archetypes
The old implementation had some issues, mostly related to the context (e.g. name, file paths) passed to the template. This new implementation is using the exact same code path for evaluating the pages as in a regular build. This also makes it more robust and easier to reason about in a multilingual setup. Now, if you are explicit about the target path, Hugo will now always pick the correct mount and language: ```bash hugo new content/en/posts/my-first-post.md ``` Fixes #9032 Fixes #7589 Fixes #9043 Fixes #9046 Fixes #9047
Diffstat (limited to 'commands')
-rw-r--r--commands/hugo.go2
-rw-r--r--commands/new.go12
-rw-r--r--commands/new_site.go2
3 files changed, 3 insertions, 13 deletions
diff --git a/commands/hugo.go b/commands/hugo.go
index 4fd20a0f4..c19756008 100644
--- a/commands/hugo.go
+++ b/commands/hugo.go
@@ -870,7 +870,7 @@ func (c *commandeer) newWatcher(pollIntervalStr string, dirList ...string) (*wat
livereload.ForceRefresh()
}
case err := <-watcher.Errors():
- if err != nil {
+ if err != nil && !os.IsNotExist(err) {
c.logger.Errorln("Error while watching:", err)
}
}
diff --git a/commands/new.go b/commands/new.go
index 7affd3547..c5b5cd182 100644
--- a/commands/new.go
+++ b/commands/new.go
@@ -80,17 +80,7 @@ func (n *newCmd) newContent(cmd *cobra.Command, args []string) error {
return newUserError("path needs to be provided")
}
- createPath := args[0]
-
- var kind string
-
- createPath, kind = newContentPathSection(c.hugo(), createPath)
-
- if n.contentType != "" {
- kind = n.contentType
- }
-
- return create.NewContent(c.hugo(), kind, createPath)
+ return create.NewContent(c.hugo(), n.contentType, args[0])
}
func mkdir(x ...string) {
diff --git a/commands/new_site.go b/commands/new_site.go
index 71097b8ff..11e9ce40a 100644
--- a/commands/new_site.go
+++ b/commands/new_site.go
@@ -102,7 +102,7 @@ func (n *newSiteCmd) doNewSite(fs *hugofs.Fs, basepath string, force bool) error
// Create a default archetype file.
helpers.SafeWriteToDisk(filepath.Join(archeTypePath, "default.md"),
- strings.NewReader(create.ArchetypeTemplateTemplate), fs.Source)
+ strings.NewReader(create.DefaultArchetypeTemplateTemplate), fs.Source)
jww.FEEDBACK.Printf("Congratulations! Your new Hugo site is created in %s.\n\n", basepath)
jww.FEEDBACK.Println(nextStepsText())