Index
Use: {{#is "index"}}{{/is}} to detect this context.
Use: {{# is "index"}} {{/ is}} This context is detected.
Description Description
index
is the name for the main post list in your Ghost site, the index
context includes the home page and subsequent pages of the main post list. The index
context is always paired with either the home
context when on the first page of your site, or the page
context when on subsequent pages.
The main index is the name of the post list Ghost in your site, index context includes a list of the main post of the home page and subsequent pages. When pagecontext on the first page or subsequent pages of your site, indexing and context always home
match the context.
Routes Route
The index context is present on both the root URL of the site, e.g. /
and also on subsequent pages of the post list, which live at /page/:num/
. All routes are customisable with dynamic routing.
index in the context of the root URL of the site, such as /, also post on the following pages list in /page/:num/
. All routes are customizable dynamic routing.
Templates Templates
The index context is rendered with index.hbs
by default. This template is required in all Ghost themes. If there is a home.hbs
present in the theme, the home page will be rendered using that instead.
Note that the index.hbs
template is also used to output the tag and author contexts, if no specific tag.hbs
or author.hbs
templates are provided.
Index is the context index.hbs渲染
of the default. This template at all Ghost topics are required. If there is home.hbs
presented in the subject, we will use it to render the home page.
Note index.hbs can also use a template to output tag and author context. If no tag.hbs or author.hbs
template.
Data Data
The index
context provides templates with access to an array of post objects and a pagination object. As with all contexts, all of the @blog
global data is also available.
The number of posts provided will depend on the post per page
setting which you can configure in your package.json file. The array will provide the correct posts for the current page number, with the posts ordered chronologically, newest first. Therefore on the home page, the theme will have access to the first 6 posts by default. On /page/2/ the theme will have access to posts 7-12.
Each of the posts can be looped through using {{#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.
The pagination object provided is the same everywhere. The best way to output pagination is to use the pagination helper.
index
Context provides access to post an array of objects and templates page objects. Like all contexts, all @blog global data is available.
The number of articles provided will depend on each page article that you can configure in the package, set in package.json file. Array will provide the correct current page postings, postings in chronological order, the first date. Therefore, on the home page, the default theme before accessing six articles. In / page / 2 /, the theme will be displayed Write 7-12 articles.
You may be used {{#foreach 'posts'}} {{/ foreach}} cycles each post. Template code block will render each post, post and access to all object properties.
Paging object provides anywhere are the same. The best way is to use the output paging paging assistant.
Helpers assistant
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 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}} helper is the best way to output pagination. This is fully customisable.
Using {{#foreach 'posts'}} {{/ foreach}} is the best way to traverse the posts and each post output.
If your subject has tag.hbs and author.hbs list of all the articles similar output file, you may want to use a partial list of articles to define your terms, such as {{> "loop"}} . Here is a detailed example illustrates this point.
{{pagination}} is the best method of outputting helper tab. It is completely customizable.
Example Code Case Code
<header>
<h1 class="page-title">