{"category":{"version":"58810495d172b61b00d73859","project":"542fe92a5eceb608003fddc8","_id":"58810495d172b61b00d7385b","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-05-13T19:08:44.260Z","from_sync":false,"order":1,"slug":"context-reference","title":"Context Reference"},"parentDoc":null,"project":"542fe92a5eceb608003fddc8","user":"542c5cfcddd3190e00228849","version":{"__v":1,"_id":"58810495d172b61b00d73859","project":"542fe92a5eceb608003fddc8","createdAt":"2017-01-19T18:25:25.206Z","releaseDate":"2017-01-19T18:25:25.206Z","categories":["58810495d172b61b00d7385a","58810495d172b61b00d7385b","58810495d172b61b00d7385c","58810495d172b61b00d7385d","58810495d172b61b00d7385e","58810495d172b61b00d7385f"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"0.11.4","version":"0.11.4"},"_id":"58810495d172b61b00d73866","__v":0,"updates":["55d4f9345082980d0009c8af"],"next":{"pages":[],"description":""},"createdAt":"2015-05-13T20:17:36.070Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":13,"body":"Use: `{{#is \"author\"}}{{/is}}` to detect this context.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Context\",\n    \"h-1\": \"Url\",\n    \"h-2\": \"Template\",\n    \"h-3\": \"Data\",\n    \"h-4\": \"Body Classes\",\n    \"0-0\": \"author\",\n    \"0-1\": \"/author/:slug/\",\n    \"1-0\": \"author, [paged](doc:paged-context)\",\n    \"0-2\": \"[author-:slug.hbs](/docs/templates#author-hbs), [author.hbs](/docs/templates#author-hbs) or [index.hbs](/docs/templates#index-hbs)\",\n    \"0-3\": \"[{post}], {pagination}, {author}\",\n    \"1-3\": \"[{post}], {pagination}, {author}\",\n    \"0-4\": \".author-template, .author-:slug\",\n    \"1-4\": \".author-template, .author-:slug .paged\",\n    \"1-1\": \"/author/:slug/page/2/\",\n    \"1-2\": \"author-:slug.hbs, author.hbs, index.hbs\"\n  },\n  \"cols\": 5,\n  \"rows\": 2\n}\n[/block]\n## Description\n\nAuthors in Ghost each get their own page which lists out the posts that user wrote. You are in the `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 not set on posts or pages written by those authors, only on the list of posts for that author.\n\n## Routes\n\nThe default URL for author pages is `/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 the user admin, no other part of the URL can be configured at present.\n\n## Templates\n\nThe default template for an author page is `index.hbs`. \n\nYou can optionally include an `author.hbs` file in your theme which will be used for author pages instead. \n\nAdditionally, you can provide a custom template for a specific author. If there is a `author-:slug.hbs` file with the `:slug` matching the user's slug this will be used instead. \n\nFor 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`.\n\nThese 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.\n\n## Data\n\nWhen in the `author` context, a template gets access to 3 objects: the [author object](/docs/author-context#author-object-attributes) which matches the route, an array of [post objects](/docs/post-context#post-object-attributes) and a [pagination object](/docs/pagination#pagination-attributes). As with all contexts, all of the `:::at:::blog` global data is also available. \n\n### Author object\n\nWhen outputting the author attributes, you can use a block expression (`{{#author}}{{/author}}`) to drop into the author scope and access all of the attributes. See a full list of attributes below:\n\n### Author object attributes\n\n- **id** - the incremental ID of the author  \n- **name** - the name of the author\n- **bio** - the bio of the author\n- **location** - the author's location\n- **website** - the author's website\n- **twitter** - the author's twitter username ([twitter_url helper](doc:twitter_url))\n- **facebook** - the author's facebook username ([facebook_url helper](doc:facebook_url))\n- **image** - the cover image associated with the tag  ([image helper](doc:image))\n- **cover** - the author's cover image\n- **url** - the web address for the tag's page ([url helper](doc:url))\n\n### Post list\n\nEach of the posts can be looped through using [`{{#foreach 'posts'}}{{/foreach}}`](doc:foreach). The template code inside the block will be rendered for each post, and have access to all of the [post object attributes](/docs/post-context#post-object-attributes).\n\n### Pagination\n\nThe [pagination object](/docs/pagination#pagination-attributes) provided is the same everywhere. The best way to output pagination is to use the [pagination](doc:pagination) helper.\n\n## Helpers\n\nThe `{{#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 [{{image}}](doc:image) and [{{url}}](doc:url) to output the author's details.\n\nUsing `{{#foreach 'posts'}}{{/foreach}}` is the best way to loop through your posts and output each one. \n\nIf 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\"}}`. There's an example showing this in detail below.\n\nThe [{{pagination}}](doc:pagination) helper is the best way to output pagination. This is fully customisable, see the [pagination helper](doc:pagination) docs for details.\n\n## Example Code\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<!-- Everything inside the #author tags pulls data from the author -->\\n{{#author}}\\n  <header>\\n  \\t{{#if image}}\\n    \\t<img src=\\\"{{image}})\\\" alt=\\\"{{name}}'s Picture\\\" />\\n    {/if}}\\n  </header>\\n\\n  <section class=\\\"author-profile\\\">   \\n  \\t<h1 class=\\\"author-title\\\">{{name}}</h1>\\n    {{#if bio}}<h2 class=\\\"author-bio\\\">{{bio}}</h2>{{/if}}\\n    \\n    <div class=\\\"author-meta\\\">\\n      {{plural ../pagination.total empty='No posts' singular='% post' plural='% posts'}}\\n     </div>\\n  </section>\\n{{/author}}\\n\\n<main role=\\\"main\\\">\\n    <!-- includes the post loop - partials/loop.hbs -->\\n    {{> \\\"loop\\\"}}\\n</main>\\n\\n<!-- Previous/next page links - displayed on every page -->\\n{{pagination}}\",\n      \"language\": \"html\",\n      \"name\": \"author.hbs\"\n    },\n    {\n      \"code\": \"<!-- This is the post loop - each post will be output using this markup -->\\n{{#foreach posts}}\\n<article class=\\\"{{post_class}}\\\">\\n\\t<header class=\\\"post-header\\\">\\n\\t\\t<h2><a href=\\\"{{url}}\\\">{{title}}</a></h2>\\n\\t</header>\\n\\t<section class=\\\"post-excerpt\\\">\\n\\t\\t<p>{{excerpt words=\\\"26\\\"}} <a class=\\\"read-more\\\" href=\\\"{{url}}\\\">...</a></p>\\n\\t</section>\\n\\t<footer class=\\\"post-meta\\\">\\n\\t\\t{{#if author.image}}<img src=\\\"{{author.image}}\\\" alt=\\\"Author image\\\" />{{/if}}\\n\\t\\t{{author}}\\n\\t\\t{{tags prefix=\\\" on \\\"}}\\n\\t\\t<time class=\\\"post-date\\\" datetime=\\\"{{date format='YYYY-MM-DD'}}\\\">{{date format=\\\"DD MMMM YYYY\\\"}}</time>\\n\\t</footer>\\n</article>\\n{{/foreach}}\",\n      \"language\": \"html\",\n      \"name\": \"partials/loop.hbs\"\n    }\n  ]\n}\n[/block]","excerpt":"The `author` context","slug":"author-context","type":"basic","title":"author"}

author

The `author` context

Use: `{{#is "author"}}{{/is}}` to detect this context. [block:parameters] { "data": { "h-0": "Context", "h-1": "Url", "h-2": "Template", "h-3": "Data", "h-4": "Body Classes", "0-0": "author", "0-1": "/author/:slug/", "1-0": "author, [paged](doc:paged-context)", "0-2": "[author-:slug.hbs](/docs/templates#author-hbs), [author.hbs](/docs/templates#author-hbs) or [index.hbs](/docs/templates#index-hbs)", "0-3": "[{post}], {pagination}, {author}", "1-3": "[{post}], {pagination}, {author}", "0-4": ".author-template, .author-:slug", "1-4": ".author-template, .author-:slug .paged", "1-1": "/author/:slug/page/2/", "1-2": "author-:slug.hbs, author.hbs, index.hbs" }, "cols": 5, "rows": 2 } [/block] ## Description Authors in Ghost each get their own page which lists out the posts that user wrote. You are in the `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 not set on posts or pages written by those authors, only on the list of posts for that author. ## Routes The default URL for author pages is `/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 the user admin, no other part of the URL can be configured at present. ## Templates The default template for an author page is `index.hbs`. You can optionally include an `author.hbs` file in your theme which will be used for author pages instead. Additionally, you can provide a custom template for a specific author. If there is a `author-:slug.hbs` file with the `:slug` matching the user's slug this will be used instead. 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. ## Data When in the `author` context, a template gets access to 3 objects: the [author object](/docs/author-context#author-object-attributes) which matches the route, an array of [post objects](/docs/post-context#post-object-attributes) and a [pagination object](/docs/pagination#pagination-attributes). As with all contexts, all of the [email protected]` global data is also available. ### Author object When outputting the author attributes, you can use a block expression (`{{#author}}{{/author}}`) to drop into the author scope and access all of the attributes. See a full list of attributes below: ### Author object attributes - **id** - the incremental ID of the author - **name** - the name of the author - **bio** - the bio of the author - **location** - the author's location - **website** - the author's website - **twitter** - the author's twitter username ([twitter_url helper](doc:twitter_url)) - **facebook** - the author's facebook username ([facebook_url helper](doc:facebook_url)) - **image** - the cover image associated with the tag ([image helper](doc:image)) - **cover** - the author's cover image - **url** - the web address for the tag's page ([url helper](doc:url)) ### Post list Each of the posts can be looped through using [`{{#foreach 'posts'}}{{/foreach}}`](doc:foreach). The template code inside the block will be rendered for each post, and have access to all of the [post object attributes](/docs/post-context#post-object-attributes). ### Pagination The [pagination object](/docs/pagination#pagination-attributes) provided is the same everywhere. The best way to output pagination is to use the [pagination](doc:pagination) helper. ## Helpers The `{{#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 [{{image}}](doc:image) and [{{url}}](doc: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 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"}}`. There's an example showing this in detail below. The [{{pagination}}](doc:pagination) helper is the best way to output pagination. This is fully customisable, see the [pagination helper](doc:pagination) docs for details. ## Example Code [block:code] { "codes": [ { "code": "<!-- Everything inside the #author tags pulls data from the author -->\n{{#author}}\n <header>\n \t{{#if image}}\n \t<img src=\"{{image}})\" alt=\"{{name}}'s Picture\" />\n {/if}}\n </header>\n\n <section class=\"author-profile\"> \n \t<h1 class=\"author-title\">{{name}}</h1>\n {{#if bio}}<h2 class=\"author-bio\">{{bio}}</h2>{{/if}}\n \n <div class=\"author-meta\">\n {{plural ../pagination.total empty='No posts' singular='% post' plural='% posts'}}\n </div>\n </section>\n{{/author}}\n\n<main role=\"main\">\n <!-- includes the post loop - partials/loop.hbs -->\n {{> \"loop\"}}\n</main>\n\n<!-- Previous/next page links - displayed on every page -->\n{{pagination}}", "language": "html", "name": "author.hbs" }, { "code": "<!-- This is the post loop - each post will be output using this markup -->\n{{#foreach posts}}\n<article class=\"{{post_class}}\">\n\t<header class=\"post-header\">\n\t\t<h2><a href=\"{{url}}\">{{title}}</a></h2>\n\t</header>\n\t<section class=\"post-excerpt\">\n\t\t<p>{{excerpt words=\"26\"}} <a class=\"read-more\" href=\"{{url}}\">...</a></p>\n\t</section>\n\t<footer class=\"post-meta\">\n\t\t{{#if author.image}}<img src=\"{{author.image}}\" alt=\"Author image\" />{{/if}}\n\t\t{{author}}\n\t\t{{tags prefix=\" on \"}}\n\t\t<time class=\"post-date\" datetime=\"{{date format='YYYY-MM-DD'}}\">{{date format=\"DD MMMM YYYY\"}}</time>\n\t</footer>\n</article>\n{{/foreach}}", "language": "html", "name": "partials/loop.hbs" } ] } [/block]