{"category":{"version":"58810495d172b61b00d73859","project":"542fe92a5eceb608003fddc8","_id":"58810495d172b61b00d7385d","__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":"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":"58810495d172b61b00d7387a","__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-05-18T11:12:44.128Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":30,"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/facebook_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/facebook_url_spec.js\\\"><i class=\\\"fa fa-check-square-o fa-right\\\"></i>Tests</a>\\n</div>\"\n}\n[/block]\nUsage: `{{facebook_url}}` or `{{facebook_url :::at:::blog.facebook}}` or `{{facebook_url \"myfavouritepage\"}}`\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"[Output](/docs/helpers#section-output), [Ghost](/docs/helpers#section-ghost)\",\n    \"h-0\": \"Type\",\n    \"h-1\": \"Parameters\",\n    \"h-2\": \"Attributes\",\n    \"0-2\": \"n/a\",\n    \"0-1\": \"facebook username (string) (optional)\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n### Description\n\nThis helper exists to make it easy to output a URL for a facebook page. Ghost has access two facebook page names/usernames for both users and for the blog itself. When used without passing a username, the helper will look for a facebook username in the current template context, and then fallback to using [email protected]`. \n\nIf there is no facebook username set, the helper will output nothing at all.\n\nIf you pass a variable or string to the helper, it will concatenate the value with the full url for a facebook page. \n\n\n### Examples\n\nOutput the author's facebook, using an `author` block:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{{#foreach posts}}\\n  {{#author}}\\n    {{#if facebook}}<a href=\\\"{{facebook_url}}\\\">Follow me on Facebook</a>{{/if}}\\n  {{/author}}\\n{{/foreach}}\",\n      \"language\": \"handlebars\"\n    },\n    {\n      \"code\": \"<a href=\\\"https://www.facebook.com/myfacebook\\\">Follow me on Facebook</a>\",\n      \"language\": \"handlebars\"\n    }\n  ]\n}\n[/block]\nOutput the author's facebook, without an `author` block:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{{#post}}\\n\\t<h1>{{title}}</h1>\\n  <p class=\\\"meta\\\">Written by {{author}}, follow me on <a href=\\\"{{facebook_url author.facebook}}\\\">facebook</a>!</p>\\n{{/post}}\",\n      \"language\": \"handlebars\"\n    },\n    {\n      \"code\": \"<h1>My Post</h1>\\n<p class=\\\"meta\\\">Written by <a href=\\\"/author/author-slug\\\">Author Name</a>, follow me on <a href=\\\"https://www.facebook.com/myfacebook\\\">facebook</a>!</p>\\n\",\n      \"language\": \"html\"\n    }\n  ]\n}\n[/block]\nOutput the blog's facebook url in the footer:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<footer class=\\\"site-footer clearfix\\\">\\n  <section class=\\\"copyright\\\">\\n    <a href=\\\"[email protected]}}\\\">[email protected]}}</a> &copy; {{date format=\\\"YYYY\\\"}}\\n  </section>\\n  <section class=\\\"facebook\\\">\\n  \\t{{!-- @blog.facebook is the default, so we don't have to specify --}}\\n    <a href=\\\"{{facebook_url}}\\\">[email protected]}}</a>\\n  </section>\\n  <section class=\\\"poweredby\\\">\\n    Proudly published with <a href=\\\"https://ghost.org\\\">Ghost</a>\\n  </section>\\n</footer>\",\n      \"language\": \"handlebars\"\n    },\n    {\n      \"code\": \"<footer class=\\\"site-footer clearfix\\\">\\n  <section class=\\\"copyright\\\">\\n    <a href=\\\"https://my-ghost-blog.com\\\">My Ghost Blog</a> &copy; 2016\\n  </section>\\n  <section class=\\\"facebook\\\">\\n    <a href=\\\"https://www.facebook.com/myghostblog\\\">facebook.com/myghostblog</a>\\n  </section>\\n  <section class=\\\"poweredby\\\">\\n    Proudly published with <a href=\\\"https://ghost.org\\\">Ghost</a>\\n  </section>\\n</footer>\",\n      \"language\": \"html\"\n    }\n  ]\n}\n[/block]\nOutput a link to any facebook page:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<p>I'm a real fan of <a href=\\\"{{facebook_url \\\"GhostbustersOfficial\\\"}}\\\">Ghostbusters!</a></p>\",\n      \"language\": \"handlebars\"\n    },\n    {\n      \"code\": \"<p>I'm a real fan of <a href=\\\"https://www.facebook.com/GhostbustersOfficial\\\">Ghostbusters!</a></p>\",\n      \"language\": \"html\"\n    }\n  ]\n}\n[/block]","excerpt":"`{{facebook_url}}` Helper - output a full url for a facebook username or page name.","slug":"facebook_url","type":"basic","title":"facebook_url"}

facebook_url

`{{facebook_url}}` Helper - output a full url for a facebook username or page name.

[block:html] { "html": "<div class=\"github-deeplinks\">\n <a href=\"https://github.com/TryGhost/Ghost/blob/0.10.0/core/server/helpers/facebook_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/facebook_url_spec.js\"><i class=\"fa fa-check-square-o fa-right\"></i>Tests</a>\n</div>" } [/block] Usage: `{{facebook_url}}` or `{{facebook_url @blog.facebook}}` or `{{facebook_url "myfavouritepage"}}` [block:parameters] { "data": { "0-0": "[Output](/docs/helpers#section-output), [Ghost](/docs/helpers#section-ghost)", "h-0": "Type", "h-1": "Parameters", "h-2": "Attributes", "0-2": "n/a", "0-1": "facebook username (string) (optional)" }, "cols": 3, "rows": 1 } [/block] ### Description This helper exists to make it easy to output a URL for a facebook page. Ghost has access two facebook page names/usernames for both users and for the blog itself. When used without passing a username, the helper will look for a facebook username in the current template context, and then fallback to using [email protected]`. If there is no facebook username set, the helper will output nothing at all. If you pass a variable or string to the helper, it will concatenate the value with the full url for a facebook page. ### Examples Output the author's facebook, using an `author` block: [block:code] { "codes": [ { "code": "{{#foreach posts}}\n {{#author}}\n {{#if facebook}}<a href=\"{{facebook_url}}\">Follow me on Facebook</a>{{/if}}\n {{/author}}\n{{/foreach}}", "language": "handlebars" }, { "code": "<a href=\"https://www.facebook.com/myfacebook\">Follow me on Facebook</a>", "language": "handlebars" } ] } [/block] Output the author's facebook, without an `author` block: [block:code] { "codes": [ { "code": "{{#post}}\n\t<h1>{{title}}</h1>\n <p class=\"meta\">Written by {{author}}, follow me on <a href=\"{{facebook_url author.facebook}}\">facebook</a>!</p>\n{{/post}}", "language": "handlebars" }, { "code": "<h1>My Post</h1>\n<p class=\"meta\">Written by <a href=\"/author/author-slug\">Author Name</a>, follow me on <a href=\"https://www.facebook.com/myfacebook\">facebook</a>!</p>\n", "language": "html" } ] } [/block] Output the blog's facebook url in the footer: [block:code] { "codes": [ { "code": "<footer class=\"site-footer clearfix\">\n <section class=\"copyright\">\n <a href=\"[email protected]}}\">[email protected]}}</a> &copy; {{date format=\"YYYY\"}}\n </section>\n <section class=\"facebook\">\n \t{{!-- @blog.facebook is the default, so we don't have to specify --}}\n <a href=\"{{facebook_url}}\">[email protected]}}</a>\n </section>\n <section class=\"poweredby\">\n Proudly published with <a href=\"https://ghost.org\">Ghost</a>\n </section>\n</footer>", "language": "handlebars" }, { "code": "<footer class=\"site-footer clearfix\">\n <section class=\"copyright\">\n <a href=\"https://my-ghost-blog.com\">My Ghost Blog</a> &copy; 2016\n </section>\n <section class=\"facebook\">\n <a href=\"https://www.facebook.com/myghostblog\">facebook.com/myghostblog</a>\n </section>\n <section class=\"poweredby\">\n Proudly published with <a href=\"https://ghost.org\">Ghost</a>\n </section>\n</footer>", "language": "html" } ] } [/block] Output a link to any facebook page: [block:code] { "codes": [ { "code": "<p>I'm a real fan of <a href=\"{{facebook_url \"GhostbustersOfficial\"}}\">Ghostbusters!</a></p>", "language": "handlebars" }, { "code": "<p>I'm a real fan of <a href=\"https://www.facebook.com/GhostbustersOfficial\">Ghostbusters!</a></p>", "language": "html" } ] } [/block]