The Ghost Themes Developer Hub

Welcome to the Ghost Themes developer hub. You'll find comprehensive guides and documentation to help you start working with Ghost Themes as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

twitter_url

{{twitter_url}} Helper - output a full url for a twitter username.

Usage: {{twitter_url}} or {{twitter_url @blog.twitter}} or {{twitter_url "@MyFavouriteUser"}}

Type
Parameters
Attributes

twitter username (string) (optional)

n/a

Description

This helper exists to make it easy to output a URL for a twitter account. Ghost has access to twitter usernames for both users and for the blog itself. When used without passing a username, the helper will look for a twitter username in the current template context, and then fallback to using @blog.twitter.

If there is no twitter 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 twitter page. If you pass the helper a string which starts with @ it will remove it to generate what twitter considers to be the "canonical" url.

Examples

Output the author's twitter, using an author block:

{{#foreach posts}}
  {{#author}}
    {{#if twitter}}<a href="{{twitter_url}}">{{twitter}}</a>{{/if}}
  {{/author}}
{{/foreach}}
<a href="https://twitter.com/mytwitter">@mytwitter</a>

Output the author's facebook, without an author block:

{{#post}}
	<h1>{{title}}</h1>
  <p class="meta">Written by {{author}}, follow me on <a href="{{twitter_url author.twitter}}">{{twitter}}</a>!</p>
{{/post}}
<h1>My Post</h1>
<p class="meta">Written by <a href="/author/author-slug">Author Name</a>, follow me on <a href="https://twitter.com/mytwitter">@mytwitter</a>!</p>

Output the blog's twitter url in the footer:

<footer class="site-footer clearfix">
  <section class="copyright">
    <a href="{{@blog.url}}">{{@blog.title}}</a> &copy; {{date format="YYYY"}}
  </section>
  <section class="twitter">
  	{{!-- @blog.twitter is the default, so we don't have to specify --}}
    <a href="{{twitter_url}}">{{@blog.twitter}}</a>
  </section>
  <section class="poweredby">
    Proudly published with <a href="https://ghost.org">Ghost</a>
  </section>
</footer>
<footer class="site-footer clearfix">
  <section class="copyright">
    <a href="https://my-ghost-blog.com">My Ghost Blog</a> &copy; 2016
  </section>
  <section class="twitter">
    <a href="https://twitter.com/myghostblog">@myghostblog</a>
  </section>
  <section class="poweredby">
    Proudly published with <a href="https://ghost.org">Ghost</a>
  </section>
</footer>

Output a link to any twitter page:

<p>I'm a real fan of <a href="{{twitter_url "@Ghostbusters"}}">Ghostbusters!</a></p>
<p>I'm a real fan of <a href="https://twitter.com/Ghostbusters">Ghostbusters!</a></p>

twitter_url

{{twitter_url}} Helper - output a full url for a twitter username.