Browse Source

Fix publish date issue and improve TableOfContents

ACTION REQUIRED (see "Updating" below)

When support for .Params.publishdate was introduced in the last few
commits it caused an issue for posts only using .Params.date. This
commit resolves that issue by falling back to .Date when .PublishDate
is not available for a post.

TableOfContents no longer appears by default and is an opt-in
feature.

Fixed a few other cosmetic bugs and added more documentation.

Updating: Remove `notoc` in any posts. It's no longer used. To display
a table of contents use `toc` instead. See README for usage.
Josh Habdas 2 years ago
parent
commit
57432839a2

+ 32
- 3
README.md View File

@@ -30,9 +30,9 @@ Head to [Hack Cabin](http://hackcabin.com) for a production example running on A
30 30
 - Related posts feature to guide readers to similar content
31 31
 - Configurable [Section Menu](#section-menu) for global site navigation
32 32
 - Simple list pagination with page indicators
33
-- Configurable post Table of Contents using the [`details` element](http://devdocs.io/html/element/details)
34
-- Custom page meta descriptions and rel meta
33
+- Optional [Table of Contents for posts](#using-the-table-of-contents)
35 34
 - Site verification with Google, Bing and Yandex
35
+- Custom page meta descriptions and links for [improved SEO and UX](#improving-seo-and-ux)
36 36
 - Default 404 page with MP4 background video
37 37
 - Full site keyboard accessibility
38 38
 - No JavaScript required unless Analytics or Disqus enabled
@@ -64,6 +64,7 @@ baseurl = "https://c74ce35e.ngrok.io" # Controls base URL
64 64
 languageCode = "en-US" # Controls html lang attribute
65 65
 title = "After Dark" # Homepage title and page title suffix
66 66
 paginate = 5 # Number of posts to show before paginating
67
+images = [] # Optional, adds a default OpenGraph image
67 68
 
68 69
 enableRobotsTXT = true # Suggested, enable robots.txt file
69 70
 googleAnalytics = "" # Optional, add tracking Id for analytics
@@ -71,7 +72,7 @@ disqusShortname = "" # Optional, add Disqus shortname for comments
71 72
 SectionPagesMenu = "main" # Enable menu system for lazy bloggers
72 73
 
73 74
 [params]
74
-  description = "" # Suggested, controls homepage description meta
75
+  description = "" # Suggested, controls default description meta
75 76
   author = "" # Optional, controls author name display on posts
76 77
   show_menu = false # Optional, set false to disable menu entirely
77 78
   powered_by = true # Optional, set false to disable credits
@@ -140,6 +141,34 @@ Test how things are looking during development using a combination of the [Faceb
140 141
 
141 142
 **Gotcha:** Relative source URLs are not currently permitted.
142 143
 
144
+## Improving SEO and UX
145
+
146
+Aside from OpenGraph and microformats After Dark uses long-standing markup concepts. Learn to use them to improve your site's SEO and usability.
147
+
148
+### Using Custom Descriptions
149
+
150
+To help your content stand out in SERPs and enable users to [quickly grok the subject matter](https://moz.com/learn/seo/meta-description) add a `description` to the front matter of your post or page:
151
+
152
+```toml
153
+description = Become a Digital Nomad in Bali: The Lost Guide
154
+```
155
+
156
+Descriptions will also be used to accent the content summaries After Dark displays in lists when the site is generated. If no custom description is provided After Dark will fallback to the description provided in `config.toml`.
157
+
158
+### Using Link Types
159
+
160
+For related content split across multiple pages in a sequence After Dark supports use of `prev` and `next` settings in your front matter. Learn more about [link types](http://devdocs.io/html/link_types).
161
+
162
+## Using the Table of Contents
163
+
164
+For longer posts its possible to automatically generate a Table of Contents. The feature uses the HTML5 [`details` element](http://devdocs.io/html/element/details) and is opt-in on a per post basis. To add a Table of Contents to a post set the following in the post front matter:
165
+
166
+```toml
167
+toc = true
168
+```
169
+
170
+To hide the Table of Contents set `toc = false` or simply remove the setting from the post front matter.
171
+
143 172
 ## Customizing CSS
144 173
 
145 174
 To customize CSS without having to tamper with theme files do the following:

+ 0
- 1
archetypes/post.md View File

@@ -1,7 +1,6 @@
1 1
 +++
2 2
 description = ""
3 3
 draft = true
4
-notoc = true
5 4
 categories = [""]
6 5
 tags = ["", ""]
7 6
 +++

+ 5
- 1
layouts/partials/post/byline.html View File

@@ -5,7 +5,11 @@
5 5
   {{ else }}
6 6
     by <span itemprop="author">{{ .Site.Params.author }}</span>
7 7
   {{ end }}
8
-  on <time datetime="{{ .PublishDate.Format "2006-01-02T15:04:05-07:00" }}">{{ .PublishDate.Format "2 Jan, 2006" }}</time>
8
+  {{ if isset .Params "publishdate" }}
9
+    on <time datetime="{{ .PublishDate.Format "2006-01-02T15:04:05-07:00" }}">{{ .PublishDate.Format "2 Jan, 2006" }}</time>
10
+  {{ else }}
11
+    on <time datetime="{{ .Date.Format "2006-01-02T15:04:05-07:00" }}">{{ .Date.Format "2 Jan, 2006" }}</time>
12
+  {{ end }}
9 13
   {{ with .Params.categories }}
10 14
     in <span itemprop="articleSection">{{ delimit (apply (apply (sort .) "partial" "post/category-link" ".") "chomp" ".") ", " " and "}}</span>
11 15
   {{ end }}

+ 1
- 1
layouts/partials/powered-by.html View File

@@ -5,6 +5,6 @@
5 5
     using the
6 6
     <a href="https://comfusion.github.io/after-dark/">After Dark</a>
7 7
     theme by
8
-    <a href="https://habd.as">Josh Habdas</a>.
8
+    <a href="http://comfusionllc.com">Comfusion LLC</a>.
9 9
   </p>
10 10
 {{ end }}

+ 4
- 2
layouts/partials/work-summary.html View File

@@ -4,10 +4,12 @@
4 4
       <a href="{{ .Permalink }}">{{ .Title }}</a>
5 5
     </h2>
6 6
     {{ if eq .Type "post" }}
7
-      <span class="muted">{{ partial "post/meta" . }}</span>
7
+      <p class="muted">{{ partial "post/meta" . }}</p>
8 8
     {{ end }}
9 9
   </header>
10
-  <blockquote itemprop="description">{{ .Description }}</blockquote>
10
+  {{ if .Description }}
11
+    <blockquote itemprop="description">{{ .Description }}</blockquote>
12
+  {{ end }}
11 13
   {{ .Summary }}
12 14
   {{ if .Truncated }}
13 15
     <p><a itemprop="url" href="{{ .RelPermalink }}">Read More&nbsp;&raquo;</a></p>

+ 5
- 3
layouts/post/single.html View File

@@ -9,10 +9,12 @@
9 9
     {{ template "_internal/schema.html" . }}
10 10
     <header>
11 11
       <h1 itemprop="headline">{{ .Title }}</h1>
12
-      <span class="muted">{{ partial "post/meta" . }}</span>
12
+      <p class="muted">{{ partial "post/meta" . }}</p>
13 13
     </header>
14
-    <blockquote>{{ .Description }}</blockquote>
15
-    {{ if not .Params.notoc }}
14
+    {{ if .Description }}
15
+      <blockquote itemprop="description">{{ .Description }}</blockquote>
16
+    {{ end }}
17
+    {{ if and (isset .Params "toc") .Params.toc  }}
16 18
       <details>
17 19
         <summary>Table of Contents</summary>
18 20
         {{ .TableOfContents }}

+ 1
- 0
theme.toml View File

@@ -86,6 +86,7 @@ min_version = 0.16
86 86
 
87 87
 ######
88 88
 # TODO:
89
+# - Add noindex meta for pages to not crawl (or custom robots.txt)
89 90
 # X Similar posts feature - https://gohugo.io/templates/functions/
90 91
 # X Check out the menu stuff in "creating a new theme md"
91 92
 # X Confirm RSS is working as expected

Loading…
Cancel
Save