On 2014-06-28 at 00:53 -0700, Bill Anderson wrote:
> A 'central' means for detailing information about each author (social
> handles, email, personal site, etc. Google authorship data). I'm
> comfortable with that being a data file such as JSON in the repo - or even
> one per author in a 'authors' directory.
> I *think* this should be doable in Hugo - but then again I'm not yet
Disclaimer: I am not a Hugo maintainer, only a patch submitter (and the
author of the feature pushed as the solution below).
It can be done now, as long as you're happy putting the data in the
top-level config file, which can be TOML, YAML or JSON.
You could use a language of your choice to make a small tool which
maintains the data in a separate JSON file but merges it into the
top-level config file. There is probably scope for more dynamic
dispatch into other config files.
Right now: you'd put the data into the `Params` section of the top-level
config file, then reference it via `.Site.Params` within template pages.
There are documented examples of using this in
<
http://hugo.spf13.com/templates/go-templates> under "Using Site
(config) Parameters" (which *cough* seems to use examples lifted
wholesale from one of my emails to the list? Works for me :) ).
The site params can be arbitrarily nested -- Hugo imposes no structure,
it's up to you to make sure that the page templates sensibly use the
parameters which you provide.
My blog's config.yaml includes:
params:
#...
FaviconPath: "/troll1.ico"
PGPkeys:
- "0x4D1E900E14C1CC04"
- "0x403043153903637F"
Mugshot: "/images/qart-pdp1-sm.png"
#...
Then, one of my chrome entries for the sidebar includes:
{{ with .Site.Params.PGPkeys }}
<div class="pgpkeys">
PGP Keys: {{ range $key := . }}
<a href="
http://ha.pool.sks-keyservers.net:11371/pks/lookup?op=index&search={{$key}}"><code>{{$key}}</code></a>{{end}}
</div>
{{ end }}
That's a sequential list, but you could use a map/dict/hash/term-du-jour
instead, and provide arbitrary author data.
params:
Authors:
Fred:
FullName: "Fred Bloggs"
Blurb: "Fred is a foo hacker"
Homepage:
http://www.example.org/fred/
Gladys:
FullName: "Gladys Bloggs"
Blurb: "Gladys puts up with Fred's idiosyncratic ways"
Homepage:
http://www.example.org/gladys/
You could then use a page `.Params` entry as a key into
`.Site.Params.Authors`; more docs on the Go template language are at:
<
http://godoc.org/text/template>
I haven't tried it, but I suspect that this would work:
{{ with .Site.Params.Authors.(.Params.Author) }}
Written by <a href="{{ .Homepage }}">{{ .Fullname }}</a>
{{ end }}
Regards,
--
My employer, Apcera Inc, is hiring sysadmin; primarily San Francisco:
http://www.apcera.com/jobs/#operations-engineer
(but all the mistakes in this email are made in my personal capacity)