Skip to content
Browse files

Adding noauthor and multiple author capability.

Cleaned up the code that renders <section class="author"> in the single layout. Extracted to a
partial, "author.html". Introduced .Params.noauthor to remove the author block entirely.
Introduced a map-based lookup into .Site.Data.authors, based on either a per-page
key, or a default Added additional checks to keep new authors partial backwards
compatible with the existing hugo-theme-casper
  • Loading branch information
bkono committed Jun 6, 2015
1 parent bed84a4 commit 55f5adbcbf60a826d27f2b32a905e10118aac557
Showing with 43 additions and 13 deletions.
  1. +19 −0
  2. +4 −0 data/authors/example.yml
  3. +1 −13 layouts/_default/single.html
  4. +19 −0 layouts/partials/author.html
@@ -66,6 +66,25 @@ Copyright = "All rights reserved - 2015"

Example : [config.toml](

## Multiple authors configuration

In addition to providing data for a single author as shown in the example above, multiple authors
can be configured via data/authors/\*.(yml, toml, json) entries. If the key provided in matched a data/authors/\* entry, it will be used as the default. Overrides
per page can be done by a simple author = other_author_key entry in the front matter. For those
pages where you want to omit the author block completely, a .Params.noauthor entry is also

Example author definition file:

``` yml
name: John Doe
bio: The most uninteresting man in the world.
location: Normal, IL

## Menu configuration

On top right of the screen, a "Subscribe" button is displayed with a link to the RSS feed.
@@ -0,0 +1,4 @@
name: "John Doe"
bio: "The most generic man in the world"
location: "Normal, Il"
website: ""
@@ -57,19 +57,7 @@ <h1 class="post-title">{{.Title}}</h1>

<section class="author">
<h4><a href="{{.Site.BaseURL}}">{{}}</a></h4>
<p>Read <a href="{{.Site.BaseURL}}">more posts</a> by this author.</p>
<div class="author-meta">
{{if .Site.Params.authorlocation}}<span class="author-location icon-location">{{.Site.Params.authorlocation}}</span>{{end}}
{{if .Site.Params.authorwebsite}}<span class="author-link icon-link"><a href="{{.Site.Params.authorwebsite}}">{{.Site.Params.authorwebsite}}</a></span>{{end}}
{{ partial "author.html" . }}

{{ if ne .Params.share false}}
<section class="share">
@@ -0,0 +1,19 @@
{{ if not .Params.noauthor }}
{{$author := index .Site.Data.authors (or}}
{{$authorname := or $ }}
{{$authorbio := or $ }}
{{$authorlocation := or $author.location .Site.Params.authorlocation }}
{{$authorwebsite := or $ .Site.Params.authorwebsite }}
<section class="author">
<h4><a href="{{.Site.BaseURL}}">{{$authorname}}</a></h4>
{{if $authorbio}}
<p>Read <a href="{{.Site.BaseURL}}">more posts</a> by this author.</p>
<div class="author-meta">
{{with $authorlocation}}<span class="author-location icon-location">{{.}}</span>{{end}}
{{with $authorwebsite}}<span class="author-link icon-link"><a href="{{.}}">{{.}}</a></span>{{end}}

0 comments on commit 55f5adb

Please sign in to comment.
You can’t perform that action at this time.