Use: {{#is "author"}}{{/is}}
to detect this context
author
context when viewing the page thats lists all posts written by that user, as well as subsequent pages of posts. The author
context is only set on the list of posts, and not on the individual post itself.
/author/:slug/
. The author
context is also set on subsequent pages of the post list, which live at /author/:slug/page/:num/
. The slug
part of the URL is based on the name of the author and can be configured in admin. To change the author URL structure, use routing.
index.hbs
or you can use an author.hbs
file in your theme to customise the author pages.
To provide a custom template for a specific author, name the file using author-:slug.hbs
, file with the :slug
matching the user’s slug. For example, if you have an author ‘John’ with the url /author/john/
, adding a template called author-john.hbs
will cause that template to be used for John’s list of posts instead of author.hbs
, or index.hbs
.
These templates exist in a hierarchy. Ghost looks for a template which matches the slug (author-:slug.hbs
) first, then looks for author.hbs
and finally uses index.hbs
if neither is available.
author
context, a template gets access to 3 objects: the author object which matches the route, an array of post objects and a pagination object. As with all contexts, all of the @site
global data is also available.
{{#author}}{{/author}}
) to drop into the author scope and access all of the attributes. See a full list of attributes below:
{{#foreach posts}}{{/foreach}}
. The template code inside the block will be rendered for each post, and have access to all of the post object attributes.
{{#author}}{{/author}}
block expression is useful for accessing all of the author attributes. Once inside the author you can access the attributes and use helpers like {{img_url}}
and {{url}}
to output the author’s details.
Using {{#foreach posts}}{{/foreach}}
is the best way to loop through your posts and output each one. If you’re using the Members feature, consider the content visibility of your posts.
If your theme does have a tag.hbs
and author.hbs
file all outputting similar post lists to index.hbs
you may wish to use a partial to define your post list item, e.g. {{> "loop"}}
.