]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
commands/new: Improve theme creation
authorJoe Mooring <joe.mooring@veriphor.com>
Sun, 30 Mar 2025 19:31:12 +0000 (12:31 -0700)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 8 Apr 2025 14:35:46 +0000 (16:35 +0200)
- Update the skeleton structure to match the new template system.
- Add a --format flag to the `hugo new theme` command to control the
  format of the site configuration and default archetype files.
- Remove theme.toml. This file's presence can be confusing for new
  users, and the README in the themes repository already has an example.
- Remove the LICENSE and README files from the skeleton. These files
  are not needed for a theme to work, and they can be added later by
  the user if desired.

Closes #13489
Closes #13544

32 files changed:
commands/new.go
create/skeletons/skeletons.go
create/skeletons/theme/LICENSE [deleted file]
create/skeletons/theme/README.md [deleted file]
create/skeletons/theme/archetypes/default.md [deleted file]
create/skeletons/theme/hugo.toml [deleted file]
create/skeletons/theme/layouts/_default/baseof.html [deleted file]
create/skeletons/theme/layouts/_default/home.html [deleted file]
create/skeletons/theme/layouts/_default/list.html [deleted file]
create/skeletons/theme/layouts/_default/single.html [deleted file]
create/skeletons/theme/layouts/_partials/footer.html [new file with mode: 0644]
create/skeletons/theme/layouts/_partials/head.html [new file with mode: 0644]
create/skeletons/theme/layouts/_partials/head/css.html [new file with mode: 0644]
create/skeletons/theme/layouts/_partials/head/js.html [new file with mode: 0644]
create/skeletons/theme/layouts/_partials/header.html [new file with mode: 0644]
create/skeletons/theme/layouts/_partials/menu.html [new file with mode: 0644]
create/skeletons/theme/layouts/_partials/terms.html [new file with mode: 0644]
create/skeletons/theme/layouts/baseof.html [new file with mode: 0644]
create/skeletons/theme/layouts/home.html [new file with mode: 0644]
create/skeletons/theme/layouts/list.html [new file with mode: 0644]
create/skeletons/theme/layouts/partials/footer.html [deleted file]
create/skeletons/theme/layouts/partials/head.html [deleted file]
create/skeletons/theme/layouts/partials/head/css.html [deleted file]
create/skeletons/theme/layouts/partials/head/js.html [deleted file]
create/skeletons/theme/layouts/partials/header.html [deleted file]
create/skeletons/theme/layouts/partials/menu.html [deleted file]
create/skeletons/theme/layouts/partials/terms.html [deleted file]
create/skeletons/theme/layouts/single.html [new file with mode: 0644]
create/skeletons/theme/layouts/taxonomy.html [new file with mode: 0644]
create/skeletons/theme/layouts/term.html [new file with mode: 0644]
create/skeletons/theme/theme.toml [deleted file]
testscripts/commands/new.txt

index 901ea02d6159b8855ff98b3f725d37a171efd12c..fdc1f65f2fcd291c80a66222f1604d95d5040dad 100644 (file)
@@ -144,7 +144,7 @@ according to your needs.`,
                                        createpath := paths.AbsPathify(conf.configs.Base.WorkingDir, filepath.Join(conf.configs.Base.ThemesDir, args[0]))
                                        r.Println("Creating new theme in", createpath)
 
-                                       err = skeletons.CreateTheme(createpath, sourceFs)
+                                       err = skeletons.CreateTheme(createpath, sourceFs, format)
                                        if err != nil {
                                                return err
                                        }
@@ -152,7 +152,14 @@ according to your needs.`,
                                        return nil
                                },
                                withc: func(cmd *cobra.Command, r *rootCommand) {
-                                       cmd.ValidArgsFunction = cobra.NoFileCompletions
+                                       cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
+                                               if len(args) != 0 {
+                                                       return []string{}, cobra.ShellCompDirectiveNoFileComp
+                                               }
+                                               return []string{}, cobra.ShellCompDirectiveNoFileComp | cobra.ShellCompDirectiveFilterDirs
+                                       }
+                                       cmd.Flags().StringVar(&format, "format", "toml", "preferred file format (toml, yaml or json)")
+                                       _ = cmd.RegisterFlagCompletionFunc("format", cobra.FixedCompletions([]string{"toml", "yaml", "json"}, cobra.ShellCompDirectiveNoFileComp))
                                },
                        },
                },
index 54b6695226d1085bb553e64c65513e5cba0537e8..a6241ef926c6905fbcdd8e4e3d4e53d3f05599e2 100644 (file)
@@ -34,10 +34,60 @@ var siteFs embed.FS
 var themeFs embed.FS
 
 // CreateTheme creates a theme skeleton.
-func CreateTheme(createpath string, sourceFs afero.Fs) error {
+func CreateTheme(createpath string, sourceFs afero.Fs, format string) error {
        if exists, _ := helpers.Exists(createpath, sourceFs); exists {
                return errors.New(createpath + " already exists")
        }
+
+       format = strings.ToLower(format)
+
+       siteConfig := map[string]any{
+               "baseURL":      "https://example.org/",
+               "languageCode": "en-US",
+               "title":        "My New Hugo Site",
+               "menus": map[string]any{
+                       "main": []any{
+                               map[string]any{
+                                       "name":    "Home",
+                                       "pageRef": "/",
+                                       "weight":  10,
+                               },
+                               map[string]any{
+                                       "name":    "Posts",
+                                       "pageRef": "/posts",
+                                       "weight":  20,
+                               },
+                               map[string]any{
+                                       "name":    "Tags",
+                                       "pageRef": "/tags",
+                                       "weight":  30,
+                               },
+                       },
+               },
+               "module": map[string]any{
+                       "hugoVersion": map[string]any{
+                               "extended": false,
+                               "min":      "0.146.0",
+                       },
+               },
+       }
+
+       err := createSiteConfig(sourceFs, createpath, siteConfig, format)
+       if err != nil {
+               return err
+       }
+
+       defaultArchetype := map[string]any{
+               "title": "{{ replace .File.ContentBaseName \"-\" \" \" | title }}",
+               "date":  "{{ .Date }}",
+               "draft": true,
+       }
+
+       err = createDefaultArchetype(sourceFs, createpath, defaultArchetype, format)
+       if err != nil {
+               return err
+       }
+
        return copyFiles(createpath, sourceFs, themeFs)
 }
 
@@ -71,12 +121,24 @@ func CreateSite(createpath string, sourceFs afero.Fs, force bool, format string)
                }
        }
 
-       err := newSiteCreateConfig(sourceFs, createpath, format)
+       siteConfig := map[string]any{
+               "baseURL":      "https://example.org/",
+               "title":        "My New Hugo Site",
+               "languageCode": "en-us",
+       }
+
+       err := createSiteConfig(sourceFs, createpath, siteConfig, format)
        if err != nil {
                return err
        }
 
-       err = newSiteCreateArchetype(sourceFs, createpath, format)
+       defaultArchetype := map[string]any{
+               "title": "{{ replace .File.ContentBaseName \"-\" \" \" | title }}",
+               "date":  "{{ .Date }}",
+               "draft": true,
+       }
+
+       err = createDefaultArchetype(sourceFs, createpath, defaultArchetype, format)
        if err != nil {
                return err
        }
@@ -99,13 +161,7 @@ func copyFiles(createpath string, sourceFs afero.Fs, skeleton embed.FS) error {
        })
 }
 
-func newSiteCreateConfig(fs afero.Fs, createpath string, format string) (err error) {
-       in := map[string]string{
-               "baseURL":      "https://example.org/",
-               "title":        "My New Hugo Site",
-               "languageCode": "en-us",
-       }
-
+func createSiteConfig(fs afero.Fs, createpath string, in map[string]any, format string) (err error) {
        var buf bytes.Buffer
        err = parser.InterfaceToConfig(in, metadecoders.FormatFromString(format), &buf)
        if err != nil {
@@ -115,13 +171,7 @@ func newSiteCreateConfig(fs afero.Fs, createpath string, format string) (err err
        return helpers.WriteToDisk(filepath.Join(createpath, "hugo."+format), &buf, fs)
 }
 
-func newSiteCreateArchetype(fs afero.Fs, createpath string, format string) (err error) {
-       in := map[string]any{
-               "title": "{{ replace .File.ContentBaseName \"-\" \" \" | title }}",
-               "date":  "{{ .Date }}",
-               "draft": true,
-       }
-
+func createDefaultArchetype(fs afero.Fs, createpath string, in map[string]any, format string) (err error) {
        var buf bytes.Buffer
        err = parser.InterfaceToFrontMatter(in, metadecoders.FormatFromString(format), &buf)
        if err != nil {
diff --git a/create/skeletons/theme/LICENSE b/create/skeletons/theme/LICENSE
deleted file mode 100644 (file)
index 8aa2645..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) [year] [fullname]
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/create/skeletons/theme/README.md b/create/skeletons/theme/README.md
deleted file mode 100644 (file)
index 7cec74e..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# Theme Name
-
-## Features
-
-## Installation
-
-## Configuration
diff --git a/create/skeletons/theme/archetypes/default.md b/create/skeletons/theme/archetypes/default.md
deleted file mode 100644 (file)
index c6f3fce..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-+++
-title = '{{ replace .File.ContentBaseName "-" " " | title }}'
-date = {{ .Date }}
-draft = true
-+++
diff --git a/create/skeletons/theme/hugo.toml b/create/skeletons/theme/hugo.toml
deleted file mode 100644 (file)
index 6c35bc4..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-baseURL = 'https://example.org/'
-languageCode = 'en-US'
-title = 'My New Hugo Site'
-
-[[menus.main]]
-name = 'Home'
-pageRef = '/'
-weight = 10
-
-[[menus.main]]
-name = 'Posts'
-pageRef = '/posts'
-weight = 20
-
-[[menus.main]]
-name = 'Tags'
-pageRef = '/tags'
-weight = 30
-
-[module]
-  [module.hugoVersion]
-    extended = false
-    min = "0.116.0"
diff --git a/create/skeletons/theme/layouts/_default/baseof.html b/create/skeletons/theme/layouts/_default/baseof.html
deleted file mode 100644 (file)
index 39dcbec..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE html>
-<html lang="{{ site.Language.LanguageCode }}" dir="{{ or site.Language.LanguageDirection `ltr` }}">
-<head>
-  {{ partial "head.html" . }}
-</head>
-<body>
-  <header>
-    {{ partial "header.html" . }}
-  </header>
-  <main>
-    {{ block "main" . }}{{ end }}
-  </main>
-  <footer>
-    {{ partial "footer.html" . }}
-  </footer>
-</body>
-</html>
diff --git a/create/skeletons/theme/layouts/_default/home.html b/create/skeletons/theme/layouts/_default/home.html
deleted file mode 100644 (file)
index 0df6597..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-{{ define "main" }}
-  {{ .Content }}
-  {{ range site.RegularPages }}
-    <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
-    {{ .Summary }}
-  {{ end }}
-{{ end }}
diff --git a/create/skeletons/theme/layouts/_default/list.html b/create/skeletons/theme/layouts/_default/list.html
deleted file mode 100644 (file)
index 50fc92d..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-{{ define "main" }}
-  <h1>{{ .Title }}</h1>
-  {{ .Content }}
-  {{ range .Pages }}
-    <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
-    {{ .Summary }}
-  {{ end }}
-{{ end }}
diff --git a/create/skeletons/theme/layouts/_default/single.html b/create/skeletons/theme/layouts/_default/single.html
deleted file mode 100644 (file)
index 7e286c8..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-{{ define "main" }}
-  <h1>{{ .Title }}</h1>
-
-  {{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00" }}
-  {{ $dateHuman := .Date | time.Format ":date_long" }}
-  <time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
-
-  {{ .Content }}
-  {{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }}
-{{ end }}
diff --git a/create/skeletons/theme/layouts/_partials/footer.html b/create/skeletons/theme/layouts/_partials/footer.html
new file mode 100644 (file)
index 0000000..a7cd916
--- /dev/null
@@ -0,0 +1 @@
+<p>Copyright {{ now.Year }}. All rights reserved.</p>
diff --git a/create/skeletons/theme/layouts/_partials/head.html b/create/skeletons/theme/layouts/_partials/head.html
new file mode 100644 (file)
index 0000000..02c2240
--- /dev/null
@@ -0,0 +1,5 @@
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width">
+<title>{{ if .IsHome }}{{ site.Title }}{{ else }}{{ printf "%s | %s" .Title site.Title }}{{ end }}</title>
+{{ partialCached "head/css.html" . }}
+{{ partialCached "head/js.html" . }}
diff --git a/create/skeletons/theme/layouts/_partials/head/css.html b/create/skeletons/theme/layouts/_partials/head/css.html
new file mode 100644 (file)
index 0000000..d76d23a
--- /dev/null
@@ -0,0 +1,9 @@
+{{- with resources.Get "css/main.css" }}
+  {{- if hugo.IsDevelopment }}
+    <link rel="stylesheet" href="{{ .RelPermalink }}">
+  {{- else }}
+    {{- with . | minify | fingerprint }}
+      <link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
+    {{- end }}
+  {{- end }}
+{{- end }}
diff --git a/create/skeletons/theme/layouts/_partials/head/js.html b/create/skeletons/theme/layouts/_partials/head/js.html
new file mode 100644 (file)
index 0000000..16ffbed
--- /dev/null
@@ -0,0 +1,16 @@
+{{- with resources.Get "js/main.js" }}
+  {{- $opts := dict
+    "minify" (not hugo.IsDevelopment)
+    "sourceMap" (cond hugo.IsDevelopment "external" "")
+    "targetPath" "js/main.js"
+  }}
+  {{- with . | js.Build $opts }}
+    {{- if hugo.IsDevelopment }}
+      <script src="{{ .RelPermalink }}"></script>
+    {{- else }}
+      {{- with . | fingerprint }}
+        <script src="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
+      {{- end }}
+    {{- end }}
+  {{- end }}
+{{- end }}
diff --git a/create/skeletons/theme/layouts/_partials/header.html b/create/skeletons/theme/layouts/_partials/header.html
new file mode 100644 (file)
index 0000000..7980a00
--- /dev/null
@@ -0,0 +1,2 @@
+<h1>{{ site.Title }}</h1>
+{{ partial "menu.html" (dict "menuID" "main" "page" .) }}
diff --git a/create/skeletons/theme/layouts/_partials/menu.html b/create/skeletons/theme/layouts/_partials/menu.html
new file mode 100644 (file)
index 0000000..14245b5
--- /dev/null
@@ -0,0 +1,51 @@
+{{- /*
+Renders a menu for the given menu ID.
+
+@context {page} page The current page.
+@context {string} menuID The menu ID.
+
+@example: {{ partial "menu.html" (dict "menuID" "main" "page" .) }}
+*/}}
+
+{{- $page := .page }}
+{{- $menuID := .menuID }}
+
+{{- with index site.Menus $menuID }}
+  <nav>
+    <ul>
+      {{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }}
+    </ul>
+  </nav>
+{{- end }}
+
+{{- define "_partials/inline/menu/walk.html" }}
+  {{- $page := .page }}
+  {{- range .menuEntries }}
+    {{- $attrs := dict "href" .URL }}
+    {{- if $page.IsMenuCurrent .Menu . }}
+      {{- $attrs = merge $attrs (dict "class" "active" "aria-current" "page") }}
+    {{- else if $page.HasMenuCurrent .Menu .}}
+      {{- $attrs = merge $attrs (dict "class" "ancestor" "aria-current" "true") }}
+    {{- end }}
+    {{- $name := .Name }}
+    {{- with .Identifier }}
+      {{- with T . }}
+        {{- $name = . }}
+      {{- end }}
+    {{- end }}
+    <li>
+      <a
+        {{- range $k, $v := $attrs }}
+          {{- with $v }}
+            {{- printf " %s=%q" $k $v | safeHTMLAttr }}
+          {{- end }}
+        {{- end -}}
+      >{{ $name }}</a>
+      {{- with .Children }}
+        <ul>
+          {{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }}
+        </ul>
+      {{- end }}
+    </li>
+  {{- end }}
+{{- end }}
diff --git a/create/skeletons/theme/layouts/_partials/terms.html b/create/skeletons/theme/layouts/_partials/terms.html
new file mode 100644 (file)
index 0000000..8a6ebec
--- /dev/null
@@ -0,0 +1,23 @@
+{{- /*
+For a given taxonomy, renders a list of terms assigned to the page.
+
+@context {page} page The current page.
+@context {string} taxonomy The taxonomy.
+
+@example: {{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }}
+*/}}
+
+{{- $page := .page }}
+{{- $taxonomy := .taxonomy }}
+
+{{- with $page.GetTerms $taxonomy }}
+  {{- $label := (index . 0).Parent.LinkTitle }}
+  <div>
+    <div>{{ $label }}:</div>
+    <ul>
+      {{- range . }}
+        <li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
+      {{- end }}
+    </ul>
+  </div>
+{{- end }}
diff --git a/create/skeletons/theme/layouts/baseof.html b/create/skeletons/theme/layouts/baseof.html
new file mode 100644 (file)
index 0000000..39dcbec
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="{{ site.Language.LanguageCode }}" dir="{{ or site.Language.LanguageDirection `ltr` }}">
+<head>
+  {{ partial "head.html" . }}
+</head>
+<body>
+  <header>
+    {{ partial "header.html" . }}
+  </header>
+  <main>
+    {{ block "main" . }}{{ end }}
+  </main>
+  <footer>
+    {{ partial "footer.html" . }}
+  </footer>
+</body>
+</html>
diff --git a/create/skeletons/theme/layouts/home.html b/create/skeletons/theme/layouts/home.html
new file mode 100644 (file)
index 0000000..0df6597
--- /dev/null
@@ -0,0 +1,7 @@
+{{ define "main" }}
+  {{ .Content }}
+  {{ range site.RegularPages }}
+    <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
+    {{ .Summary }}
+  {{ end }}
+{{ end }}
diff --git a/create/skeletons/theme/layouts/list.html b/create/skeletons/theme/layouts/list.html
new file mode 100644 (file)
index 0000000..50fc92d
--- /dev/null
@@ -0,0 +1,8 @@
+{{ define "main" }}
+  <h1>{{ .Title }}</h1>
+  {{ .Content }}
+  {{ range .Pages }}
+    <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
+    {{ .Summary }}
+  {{ end }}
+{{ end }}
diff --git a/create/skeletons/theme/layouts/partials/footer.html b/create/skeletons/theme/layouts/partials/footer.html
deleted file mode 100644 (file)
index a7cd916..0000000
+++ /dev/null
@@ -1 +0,0 @@
-<p>Copyright {{ now.Year }}. All rights reserved.</p>
diff --git a/create/skeletons/theme/layouts/partials/head.html b/create/skeletons/theme/layouts/partials/head.html
deleted file mode 100644 (file)
index 02c2240..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<meta charset="utf-8">
-<meta name="viewport" content="width=device-width">
-<title>{{ if .IsHome }}{{ site.Title }}{{ else }}{{ printf "%s | %s" .Title site.Title }}{{ end }}</title>
-{{ partialCached "head/css.html" . }}
-{{ partialCached "head/js.html" . }}
diff --git a/create/skeletons/theme/layouts/partials/head/css.html b/create/skeletons/theme/layouts/partials/head/css.html
deleted file mode 100644 (file)
index 91b928d..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-{{- with resources.Get "css/main.css" }}
-  {{- if eq hugo.Environment "development" }}
-    <link rel="stylesheet" href="{{ .RelPermalink }}">
-  {{- else }}
-    {{- with . | minify | fingerprint }}
-      <link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
-    {{- end }}
-  {{- end }}
-{{- end }}
diff --git a/create/skeletons/theme/layouts/partials/head/js.html b/create/skeletons/theme/layouts/partials/head/js.html
deleted file mode 100644 (file)
index 18fe842..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-{{- with resources.Get "js/main.js" }}
-  {{- if eq hugo.Environment "development" }}
-    {{- with . | js.Build }}
-      <script src="{{ .RelPermalink }}"></script>
-    {{- end }}
-  {{- else }}
-    {{- $opts := dict "minify" true }}
-    {{- with . | js.Build $opts | fingerprint }}
-      <script src="{{ .RelPermalink }}" integrity="{{- .Data.Integrity }}" crossorigin="anonymous"></script>
-    {{- end }}
-  {{- end }}
-{{- end }}
diff --git a/create/skeletons/theme/layouts/partials/header.html b/create/skeletons/theme/layouts/partials/header.html
deleted file mode 100644 (file)
index 7980a00..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-<h1>{{ site.Title }}</h1>
-{{ partial "menu.html" (dict "menuID" "main" "page" .) }}
diff --git a/create/skeletons/theme/layouts/partials/menu.html b/create/skeletons/theme/layouts/partials/menu.html
deleted file mode 100644 (file)
index 7183180..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-{{- /*
-Renders a menu for the given menu ID.
-
-@context {page} page The current page.
-@context {string} menuID The menu ID.
-
-@example: {{ partial "menu.html" (dict "menuID" "main" "page" .) }}
-*/}}
-
-{{- $page := .page }}
-{{- $menuID := .menuID }}
-
-{{- with index site.Menus $menuID }}
-  <nav>
-    <ul>
-      {{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }}
-    </ul>
-  </nav>
-{{- end }}
-
-{{- define "partials/inline/menu/walk.html" }}
-  {{- $page := .page }}
-  {{- range .menuEntries }}
-    {{- $attrs := dict "href" .URL }}
-    {{- if $page.IsMenuCurrent .Menu . }}
-      {{- $attrs = merge $attrs (dict "class" "active" "aria-current" "page") }}
-    {{- else if $page.HasMenuCurrent .Menu .}}
-      {{- $attrs = merge $attrs (dict "class" "ancestor" "aria-current" "true") }}
-    {{- end }}
-    {{- $name := .Name }}
-    {{- with .Identifier }}
-      {{- with T . }}
-        {{- $name = . }}
-      {{- end }}
-    {{- end }}
-    <li>
-      <a
-        {{- range $k, $v := $attrs }}
-          {{- with $v }}
-            {{- printf " %s=%q" $k $v | safeHTMLAttr }}
-          {{- end }}
-        {{- end -}}
-      >{{ $name }}</a>
-      {{- with .Children }}
-        <ul>
-          {{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }}
-        </ul>
-      {{- end }}
-    </li>
-  {{- end }}
-{{- end }}
diff --git a/create/skeletons/theme/layouts/partials/terms.html b/create/skeletons/theme/layouts/partials/terms.html
deleted file mode 100644 (file)
index 8a6ebec..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-{{- /*
-For a given taxonomy, renders a list of terms assigned to the page.
-
-@context {page} page The current page.
-@context {string} taxonomy The taxonomy.
-
-@example: {{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }}
-*/}}
-
-{{- $page := .page }}
-{{- $taxonomy := .taxonomy }}
-
-{{- with $page.GetTerms $taxonomy }}
-  {{- $label := (index . 0).Parent.LinkTitle }}
-  <div>
-    <div>{{ $label }}:</div>
-    <ul>
-      {{- range . }}
-        <li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
-      {{- end }}
-    </ul>
-  </div>
-{{- end }}
diff --git a/create/skeletons/theme/layouts/single.html b/create/skeletons/theme/layouts/single.html
new file mode 100644 (file)
index 0000000..7e286c8
--- /dev/null
@@ -0,0 +1,10 @@
+{{ define "main" }}
+  <h1>{{ .Title }}</h1>
+
+  {{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00" }}
+  {{ $dateHuman := .Date | time.Format ":date_long" }}
+  <time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
+
+  {{ .Content }}
+  {{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }}
+{{ end }}
diff --git a/create/skeletons/theme/layouts/taxonomy.html b/create/skeletons/theme/layouts/taxonomy.html
new file mode 100644 (file)
index 0000000..c2e7875
--- /dev/null
@@ -0,0 +1,7 @@
+{{ define "main" }}
+  <h1>{{ .Title }}</h1>
+  {{ .Content }}
+  {{ range .Pages }}
+    <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
+  {{ end }}
+{{ end }}
diff --git a/create/skeletons/theme/layouts/term.html b/create/skeletons/theme/layouts/term.html
new file mode 100644 (file)
index 0000000..c2e7875
--- /dev/null
@@ -0,0 +1,7 @@
+{{ define "main" }}
+  <h1>{{ .Title }}</h1>
+  {{ .Content }}
+  {{ range .Pages }}
+    <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
+  {{ end }}
+{{ end }}
diff --git a/create/skeletons/theme/theme.toml b/create/skeletons/theme/theme.toml
deleted file mode 100644 (file)
index 3ba3164..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-name = 'Theme name'
-license = 'MIT'
-licenselink = 'https://github.com/owner/repo/LICENSE'
-description = 'Theme description'
-
-# The home page of the theme, where the source can be found
-homepage = 'https://github.com/owner/repo'
-
-# If you have a running demo of the theme
-demosite = 'https://owner.github.io/repo'
-
-# Taxonomy terms
-tags = ['blog', 'company']
-features = ['some', 'awesome', 'features']
-
-# If the theme has multiple authors
-authors = [
-  {name = 'Name of author', homepage = 'Website of author'},
-  {name = 'Name of author', homepage = 'Website of author'}
-]
-
-# If the theme has a single author
-[author]
-  name = 'Your name'
-  homepage = 'Your website'
-
-# If porting an existing theme
-[original]
-  author = 'Name of original author'
-  homepage = 'Website of original author'
-  repo = 'https://github.com/owner/repo'
index 9057f9972a4829a7a7540f889889616222ffa765..433e238bfc7721031198a82ad0df9175abc444be 100644 (file)
@@ -20,7 +20,7 @@ exists themes
 
 hugo new theme -h
 stdout 'Create a new theme \(skeleton\) called \[name\] in ./themes'
-hugo new theme mytheme
+hugo new theme mytheme --format yml
 stdout 'Creating new theme'
 ! exists resources
 cd themes
@@ -34,22 +34,21 @@ checkfile content/posts/post-1.md
 checkfile content/posts/post-2.md
 checkfile content/posts/post-3/bryce-canyon.jpg
 checkfile content/posts/post-3/index.md
-checkfile layouts/_default/baseof.html
-checkfile layouts/_default/home.html
-checkfile layouts/_default/list.html
-checkfile layouts/_default/single.html
-checkfile layouts/partials/footer.html
-checkfile layouts/partials/head.html
-checkfile layouts/partials/head/css.html
-checkfile layouts/partials/head/js.html
-checkfile layouts/partials/header.html
-checkfile layouts/partials/menu.html
-checkfile layouts/partials/terms.html
+checkfile layouts/baseof.html
+checkfile layouts/home.html
+checkfile layouts/list.html
+checkfile layouts/single.html
+checkfile layouts/taxonomy.html
+checkfile layouts/term.html
+checkfile layouts/_partials/footer.html
+checkfile layouts/_partials/head.html
+checkfile layouts/_partials/head/css.html
+checkfile layouts/_partials/head/js.html
+checkfile layouts/_partials/header.html
+checkfile layouts/_partials/menu.html
+checkfile layouts/_partials/terms.html
 checkfile static/favicon.ico
-checkfile LICENSE
-checkfile README.md
-checkfile hugo.toml
-checkfile theme.toml
+checkfile hugo.yml
 exists data
 exists i18n