Gift Links for Ghost

Let members share paywalled posts with anyone.

Adds a "Gift this article" button to your Ghost site that appears when members are on a post that requires paid access. The button generates a link they can share with non-members to read the post. Links can optionally expire or have a max number of views. The code is open source and the giftlinks.net hosted version is free.

Setup

  1. In Ghost Admin, go to Members and create a new member with the email bot a𝗍 giftlinks.net. Give it a complimentary subscription to a paid tier.
  2. Enter your Ghost site URL below and click Connect. This sends the bot the sign-in email it needs to read your paywalled posts.
  3. Configure your gift link settings (both optional):

    Leave blank for defaults (14-day expiry, no view limit). "0" means unlimited.
    If you use a custom theme you may also need to set up selectors. See Gift Links Configuration.

  4. In Ghost Admin, go to Settings → Code injection and paste this in the Site footer:
    <script src="https://giftlinks.net/client.js" defer></script>

How it works

A small script on your site adds a "Gift this article" button to paywalled posts for paying members.

Sharing a post:
'Gift this article' buttonA member of your site clicks this button.
→
giftlinks.net verifies & creates linkA unique gift URL is generated and stored.
→
Gift URL copied to clipboardA special link to the post with ?gift=xxxxx on the end.
Opening a gift link:
Visitor arrives at your siteGhost shows the paywall as usual.
→
Script sends token to giftlinks.netThe bot fetches the full post using its comped membership.
→
Full article appears inlineThe script replaces paywall with full post content.

Features

FAQ

What does it cost? The service is free. It's very inexpensive to host. Maybe there will be a Pro version some day, but the basic app will stay free.

Is the source code available? Yes! github.com/elidickinson/gift-links-for-ghost

Does the bot have admin access? No. The bot is a regular comped member. It can only read content a paid subscriber would see.

What happens when a gift link expires? The visitor sees the normal paywalled post with a message the gift link is expired. Nothing breaks.

Can a gift link be shared with multiple people? Yes. The link will work without limits until it expires or the max views limit is hit.

How do I uninstall? Remove the code injection line and delete the bot member from Ghost Admin.

Are you doing something sneaky with my content/data? No. See the privacy policy.

More questions? Email me eli а𝗍 elidickinson do𝗍 com or find me on Bluesky @eli.pizza

Gift Links Configuration

Add these attributes to the script tag to configure gift link behavior. All are optional; the script guesses sensible defaults for standard Ghost themes.

AttributeDescription
data-gl4g-ttl-daysHow many days each gift link stays active. Without it, links expire after 14 days.
data-gl4g-max-viewsLimit how many times each gift link can be viewed. Without it, links are unlimited until they expire.
data-gl4g-contentCSS selector for the post content container. By default the script tries: .gh-content, .post-content, .post__content, .post-body, article.post, article, .content. You will need to set a selector here if those don't work for your theme.
data-gl4g-gateCSS selector for the paywall element. If this element is on the page then the post is currently paywalled and the visitor doesn't have access. By default the script tries: .gh-post-upgrade-cta, .gh-cta, .single-cta, .content-cta, .post-sneak-peek. The selector should only match at most one element on the page.
data-gl4g-barBy default the script adds a message bar at the top of the post if it needs to say something about gift links. You can set a selector here and it will use that spot instead (replacing anything currently inside it)
data-gl4g-apiCustom worker URL if you are self-hosting instead of using giftlinks.net (default: https://giftlinks.net).
<script src="https://giftlinks.net/client.js" defer
  data-gl4g-ttl-days="7"
  data-gl4g-max-views="10"
  data-gl4g-content="article.post">
</script>
Customize wording

Override any user-facing string by setting window.gl4g_strings in Ghost Code Injection before the client script:

<script>
window.gl4g_strings = {
  button_text: 'Share this post',
  gift_banner: 'This article was shared with you by {name}.',
};
</script>
<script src="https://giftlinks.net/client.js" defer></script>
KeyDefault
button_textGift this article
creating_textCreating link…
loading_textLoading gifted article…
expired_textThis gift link has expired.
limit_textThis gift link has reached its view limit.
error_textThere was a problem loading your gift link. Reload the page to try again.
created_textGift link created! Copy it below…
gift_bannerYou’re accessing a gift link. Subscribe… (HTML ok, {name} placeholder)
copy_textCopy
copied_textCopied!

Set any string to an empty value ('') to hide that element entirely.

Customize button placement

By default, the gift button is a floating element in the bottom-left corner. Place your own button anywhere in your theme using gl4g-button — the script will find it and attach the click handler.

If your theme has access to @member.paid, Ghost handles visibility for you:

{{#if @member.paid}}
  <a href="#" class="gl4g-button gh-btn">Gift this article</a>
{{/if}}

If your button is always in the HTML (e.g. in Code Injection, which doesn’t support Handlebars), wrap it so it stays hidden until the script activates it:

<div class="gl4g-button-wrapper" style="display:none">
  <a href="#" class="gl4g-button gh-btn">Gift this article</a>
</div>

The script only looks for .gl4g-button. You control the element type, text, and styling. If a .gl4g-button-wrapper parent exists, the script unhides it when the button is activated.

CSS: To customize styles, target the .gl4g- prefixed classes in Code Injection. For example, use .gh-content .gl4g-bar for the banner and .gl4g-button for the gift button.