@@ -30,10 +30,11 @@ import (
3030func NewContent (
3131 ps * helpers.PathSpec ,
3232 siteFactory func (filename string , siteUsed bool ) (* hugolib.Site , error ), kind , targetPath string ) error {
33+ ext := helpers .Ext (targetPath )
3334
34- jww .INFO .Println ("attempting to create " , targetPath , "of" , kind )
35+ jww .INFO .Printf ("attempting to create %q of %q of ext %q " , targetPath , kind , ext )
3536
36- archetypeFilename := findArchetype (ps , kind )
37+ archetypeFilename := findArchetype (ps , kind , ext )
3738
3839 f , err := ps .Fs .Source .Open (archetypeFilename )
3940 if err != nil {
@@ -84,7 +85,7 @@ func NewContent(
8485// FindArchetype takes a given kind/archetype of content and returns an output
8586// path for that archetype. If no archetype is found, an empty string is
8687// returned.
87- func findArchetype (ps * helpers.PathSpec , kind string ) (outpath string ) {
88+ func findArchetype (ps * helpers.PathSpec , kind , ext string ) (outpath string ) {
8889 search := []string {ps .AbsPathify (ps .Cfg .GetString ("archetypeDir" ))}
8990
9091 if ps .Cfg .GetString ("theme" ) != "" {
@@ -100,13 +101,16 @@ func findArchetype(ps *helpers.PathSpec, kind string) (outpath string) {
100101 // If the new content isn't in a subdirectory, kind == "".
101102 // Therefore it should be excluded otherwise `is a directory`
102103 // error will occur. github.com/gohugoio/hugo/issues/411
103- var pathsToCheck []string
104+ var pathsToCheck = []string { "default" }
104105
105- if kind == "" {
106- pathsToCheck = []string {"default.md" , "default" }
107- } else {
108- pathsToCheck = []string {kind + ".md" , kind , "default.md" , "default" }
106+ if ext != "" {
107+ if kind != "" {
108+ pathsToCheck = append ([]string {kind + ext , "default" + ext }, pathsToCheck ... )
109+ } else {
110+ pathsToCheck = append ([]string {"default" + ext }, pathsToCheck ... )
111+ }
109112 }
113+
110114 for _ , p := range pathsToCheck {
111115 curpath := filepath .Join (x , p )
112116 jww .DEBUG .Println ("checking" , curpath , "for archetypes" )
0 commit comments