{"category":{"version":"58c81e8e693cdd1900606acf","project":"542fe92a5eceb608003fddc8","_id":"58c81e8e693cdd1900606ad3","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-10-04T12:45:40.548Z","from_sync":false,"order":3,"slug":"helper-reference","title":"Helper Reference"},"parentDoc":null,"project":"542fe92a5eceb608003fddc8","user":"542c5cfcddd3190e00228849","version":{"__v":1,"_id":"58c81e8e693cdd1900606acf","project":"542fe92a5eceb608003fddc8","createdAt":"2017-03-14T16:47:10.620Z","releaseDate":"2017-03-14T16:47:10.620Z","categories":["58c81e8e693cdd1900606ad0","58c81e8e693cdd1900606ad1","58c81e8e693cdd1900606ad2","58c81e8e693cdd1900606ad3","58c81e8e693cdd1900606ad4","58c81e8e693cdd1900606ad5"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"0.11.7","version":"0.11.7"},"_id":"58c81e8e693cdd1900606af6","__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2014-10-26T10:31:21.242Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"never","params":[],"url":""},"isReference":false,"order":43,"body":"[block:html]\n{\n  \"html\": \"<div class=\\\"github-deeplinks\\\">\\n    <a href=\\\"https://github.com/TryGhost/Ghost/blob/0.10.0/core/server/helpers/page_url.js\\\"><i class=\\\"fa fa-github-alt fa-right\\\"></i>Source</a>\\n    <a href=\\\"https://github.com/TryGhost/Ghost/blob/0.10.0/core/test/unit/server_helpers/page_url_spec.js\\\" class=\\\"fa fa-check-square-o fa-right\\\">Tests</a>\\n</div>\"\n}\n[/block]\nUsage: `{{page_url 2}}` or `{{page_url next}}` or `{{page_url \"next\"}}`\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Type\",\n    \"h-1\": \"Parameters\",\n    \"h-2\": \"Attributes\",\n    \"0-0\": \"[Output](/docs/helpers#section-output), [Ghost](/docs/helpers#section-ghost)\",\n    \"0-1\": \"page number (number)\\nor \\n\\\"next\\\" or \\\"prev\\\" (string)\",\n    \"0-2\": \"n/a\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n### Description\n\nThis helper is used in the pagination template required by the [`{{pagination}}` helper](doc:pagination) to output the URL for the next, previous or a specific page. It expects a variable which contains the page number you want to output.\n\nThe helper can also interpret the strings \"next\" and \"prev\", to display a next/previous link outside of the context of pagination.\n\n### Examples\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Hint\",\n  \"body\": \"Switch between the Handlebars and HTML tabs to see the the output from the helper\"\n}\n[/block]\nHandlebars from the default [pagination.hbs](https://github.com/TryGhost/Ghost/blob/0.8.0/core/server/helpers/tpl/pagination.hbs) template, HTML shows the output when on page 2 of 3.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<nav class=\\\"pagination\\\" role=\\\"navigation\\\">\\n    {{#if prev}}\\n        <a class=\\\"newer-posts\\\" href=\\\"{{page_url prev}}\\\">&larr; Newer Posts</a>\\n    {{/if}}\\n    <span class=\\\"page-number\\\">Page {{page}} of {{pages}}</span>\\n    {{#if next}}\\n        <a class=\\\"older-posts\\\" href=\\\"{{page_url next}}\\\">Older Posts &rarr;</a>\\n    {{/if}}\\n</nav>\",\n      \"language\": \"html\",\n      \"name\": \"Handlebars\"\n    },\n    {\n      \"code\": \"<nav class=\\\"pagination\\\" role=\\\"navigation\\\">\\n    <a class=\\\"newer-posts\\\" href=\\\"/\\\">&larr; Newer Posts</a>\\n    <span class=\\\"page-number\\\">Page 2 of 3</span>\\n    <a class=\\\"older-posts\\\" href=\\\"/page/3/\\\">Older Posts &rarr;</a>\\n</nav>\",\n      \"language\": \"html\"\n    }\n  ]\n}\n[/block]","excerpt":"`{{page_url}}` Helper - Output the URL for a given page in a list (i.e. next page)","slug":"page_url","type":"basic","title":"page_url"}

page_url

`{{page_url}}` Helper - Output the URL for a given page in a list (i.e. next page)

[block:html] { "html": "<div class=\"github-deeplinks\">\n <a href=\"https://github.com/TryGhost/Ghost/blob/0.10.0/core/server/helpers/page_url.js\"><i class=\"fa fa-github-alt fa-right\"></i>Source</a>\n <a href=\"https://github.com/TryGhost/Ghost/blob/0.10.0/core/test/unit/server_helpers/page_url_spec.js\" class=\"fa fa-check-square-o fa-right\">Tests</a>\n</div>" } [/block] Usage: `{{page_url 2}}` or `{{page_url next}}` or `{{page_url "next"}}` [block:parameters] { "data": { "h-0": "Type", "h-1": "Parameters", "h-2": "Attributes", "0-0": "[Output](/docs/helpers#section-output), [Ghost](/docs/helpers#section-ghost)", "0-1": "page number (number)\nor \n\"next\" or \"prev\" (string)", "0-2": "n/a" }, "cols": 3, "rows": 1 } [/block] ### Description This helper is used in the pagination template required by the [`{{pagination}}` helper](doc:pagination) to output the URL for the next, previous or a specific page. It expects a variable which contains the page number you want to output. The helper can also interpret the strings "next" and "prev", to display a next/previous link outside of the context of pagination. ### Examples [block:callout] { "type": "info", "title": "Hint", "body": "Switch between the Handlebars and HTML tabs to see the the output from the helper" } [/block] Handlebars from the default [pagination.hbs](https://github.com/TryGhost/Ghost/blob/0.8.0/core/server/helpers/tpl/pagination.hbs) template, HTML shows the output when on page 2 of 3. [block:code] { "codes": [ { "code": "<nav class=\"pagination\" role=\"navigation\">\n {{#if prev}}\n <a class=\"newer-posts\" href=\"{{page_url prev}}\">&larr; Newer Posts</a>\n {{/if}}\n <span class=\"page-number\">Page {{page}} of {{pages}}</span>\n {{#if next}}\n <a class=\"older-posts\" href=\"{{page_url next}}\">Older Posts &rarr;</a>\n {{/if}}\n</nav>", "language": "html", "name": "Handlebars" }, { "code": "<nav class=\"pagination\" role=\"navigation\">\n <a class=\"newer-posts\" href=\"/\">&larr; Newer Posts</a>\n <span class=\"page-number\">Page 2 of 3</span>\n <a class=\"older-posts\" href=\"/page/3/\">Older Posts &rarr;</a>\n</nav>", "language": "html" } ] } [/block]