- HTML 54.8%
- JavaScript 18.8%
- Handlebars 16.3%
- Shell 10.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| example | ||
| node-tests | ||
| partials | ||
| .gitignore | ||
| build-zip.sh | ||
| LICENSE | ||
| package.json | ||
| README.de.md | ||
| README.md | ||
| theme-settings.example.en.json | ||
| theme-settings.example.json | ||
affilinode for Ghost
Version 1.0.0 · License: MIT (see LICENSE) · Repository: https://git.valitype.com/affilinode/affilinode-ghost
Deutsch · English
Product boxes, price comparisons and matching products in your Ghost blog – no programming needed. You write in the Ghost editor as usual; a script turns shortcodes and product links into boxes with your affiliate links and tracking IDs. An affilinode account is required.
Ghost has no server plugins, so the integration is a single script tag (code injection), optionally a theme partial for theme developers – and this guide.
| File | Purpose |
|---|---|
README.md, README.de.md |
This guide (English, German) |
partials/affilinode.hbs |
Optional: partial for theme developers, settings in Ghost's customizer |
theme-settings.example.json |
The matching entries for package.json → config.custom (German labels) |
theme-settings.example.en.json |
The same entries with English labels |
example/index.html |
Test page in Ghost markup (using the demo key) |
Fastest: the wizard in the dashboard
In the affilinode dashboard open Integrations → Ghost → Set up. The wizard does steps 1 and 2 below in one go:
- Blog – enter the address; choose or create a website, an embed key with the domain is created.
- Look – shortcodes, links → boxes/rows, maximum per post, context box after paragraph n; with a live preview of a post in Ghost style (sample data or one of your own products).
- Install – a ready-made snippet to copy and the direct link
<blog>/ghost/#/settings/code-injection. - Check – affilinode fetches the blog and reports "found", "different key", "not found" or "not reachable".
The steps by hand:
1. Create an embed key
- In the affilinode dashboard open the website for your blog (or create it) under Websites and choose Embedding.
- Under Domains enter the domain of your blog, e.g.
myblog.com(applies with and withoutwww). For Ghost(Pro) without a custom domain use the addressmyblog.ghost.io. Several domains separated by commas or one per line. - Create key.
The key later appears in the source of your pages. That is intended: it is read-only and only works on the allowed domains.
2. Add the script to Ghost (code injection)
- In the dashboard, under Create code, choose the tab Ghost & forums, set the options and Copy code.
- In Ghost: Settings → section Advanced → Code injection → Open.
- Paste the code into the Site footer field and Save.
A finished example with all three features:
<script
src="https://api.affilinode.com/v1/embed/embed.js"
data-key="YOUR-KEY"
data-shortcodes="1"
data-links="box"
data-context-after="3"
async
></script>
Code injection in the footer applies to all pages of the blog. If you only need the script in individual posts, use the post's own code injection instead (post settings → Code injection → Post footer).
Options on the script tag
| Attribute | Values | Effect |
|---|---|---|
data-key |
key | Required. Your embed key. |
data-shortcodes |
1 |
Shortcodes like [affilinode_product id="…"] in the text become boxes. |
data-links |
box, compact, off (default) |
Supported product links become product boxes or compact rows. |
data-links-max |
number, default 3 |
At most this many boxes from links per post. |
data-links-scope |
CSS selector | Where to look. Default: [data-affilinode-content], .gh-content, .cooked, article, main. |
data-context-after |
number | "Matching this post" box after the n-th paragraph (Publisher plan). |
data-context-limit |
number, default 3 |
Number of products in the context box. |
data-context-title |
text | Own heading for the context box. |
data-theme |
light (default), dark, auto |
Colour scheme; auto follows the reader's system. |
data-accent, data-cta-color |
#rrggbb |
Accent colour and colour of the buy button. |
data-locale, data-country |
e.g. en-GB, AT |
Language and country. Without a language the page's <html lang> is used, without a country the visitor's country. |
data-price-age |
relative (default), datetime, off |
"Price updated 2 hr. ago" per offer; the age is calculated by the browser (correct even when cached). |
data-max-age |
hours, default 24 |
Hide older prices, button "Check current price" (Amazon never above 24 hours). Per shortcode max_age=…. |
3. Boxes in the editor
Shortcode in a paragraph
Write the shortcode in an ordinary paragraph:
[affilinode_product id="asin:B0XXXXXXXX"]
If the shortcode is alone in its paragraph, the box replaces the paragraph. If it sits in the middle of the text, the
paragraph is split there. Specify products as in the WordPress plugin: affilinode ID, asin:…, gtin:…. Quotation
marks are optional.
| Shortcode | Layout |
|---|---|
[affilinode_product id=…] |
Product box |
[affilinode_offers id=…] |
Price comparison of all offers (packs=tabs: tab per pack size) |
[affilinode_packs id=…] |
Pack sizes with price per piece |
[affilinode_button id=…] |
Buy button |
[affilinode_products ids=a,b,c] |
Cards side by side |
[affilinode_compare ids=a,b] |
Comparison table |
[affilinode_list id=…] |
Best-of list |
[affilinode_price_history id=…] |
Price history |
[affilinode_tariffs id=…] |
Device + tariffs |
[affilinode_product id=… template=card] |
Product card |
[affilinode_rating id=…] |
Test rating |
[affilinode_glance id=…] |
At a glance |
[affilinode_energy id=…] |
Running costs |
[affilinode_alternatives id=…] |
Alternatives |
[affilinode_link id=… text=…] |
Text link in a sentence |
[affilinode_field id=… field=price] |
Single value in a sentence |
[affilinode_search type=…] |
Product search |
[affilinode_advisor id=…] |
Product advisor |
[affilinode_compat system=…] |
Compatibility check |
[affilinode_top type=…] |
Best in category |
[affilinode_scatter type=… field=…] |
Price-performance chart |
The attributes are named as in the WordPress plugin (e.g. per_page, by, kinds). Insert product in the
dashboard (Integrations, tab "Ghost") builds the finished shortcode with all options and a preview.
Ghost's editor cannot turn a shortcode into a box while you type – in the editor and in the editor's preview you therefore see the text. The box appears on the published page (and in Preview).
HTML card
Alternatively type /html or add an HTML card via + and write the placeholder into it:
<div data-affilinode="product" data-id="asin:B0XXXXXXXX"></div>
All layouts of the embed work this way (compare with data-ids, list with data-list …). Insert product in
the dashboard (Integrations) delivers the placeholder or shortcode with product search and preview; the tab
Single boxes under Websites → Embedding offers the same box types and options. For the HTML card you do not need
data-shortcodes.
Product links
With data-links="box" a link is enough:
- Recognised are Amazon (
/dp/<ASIN>,/gp/product/<ASIN>, any Amazon domain), eBay (/itm/<number>), Awin deep links and links to offers that affilinode knows in your catalogue. - Link alone in a paragraph (bare URL): the box replaces the paragraph.
- Link in the middle of a sentence: the link stays, the box follows the paragraph.
- Not converted are links in quotes, in code and unknown links. Short links such as
amzn.toare not resolved.
The box uses your affiliate links and tracking IDs – even if the original link carried a different partner ID.
Note: if you paste a bare URL into an empty line in Ghost, the editor often turns it into a bookmark card instead of a paragraph. A link that is text inside a paragraph reliably becomes a box: write a word or a sentence, select it and link it with Ctrl+K (Mac: Cmd+K).
4. Products matching the post
data-context-after="3" puts a box with products from your catalogue that match the topic of the post after the 3rd
paragraph. For this the script reads the title, headings and the beginning of the post (at most 2,000 characters).
- Included in the Publisher plan (feature "Matching the content"). In other plans the box stays empty – the generator in the dashboard then shows a note. Shortcodes and links work in every plan.
- At a specific spot instead of automatically: an HTML card with
<div data-affilinode="context"></div>. - On pages without paragraphs in the content (home page, tag pages) no context box appears.
5. Ghost specifics
Content area (.gh-content)
Ghost themes output the post in <section class="gh-content"> – so do the official themes Source and Casper
and most others. The script looks there (and in article, main). If your theme shows the content differently,
name the area:
<script
src="https://api.affilinode.com/v1/embed/embed.js"
data-key="YOUR-KEY"
data-links="box"
data-links-scope=".post-content"
async
></script>
Navigation, header and footer are always left out.
Members and paywall
For members-only posts Ghost only delivers the public part (up to the Public preview divider) plus the sign-up notice to non-members. Boxes are only created from what the reader actually sees: shortcodes and links behind the paywall are seen by members only, the context box is based on the visible text. Links in the sign-up notice are not converted.
Newsletter (email)
Ghost also sends posts as a newsletter. Emails do not run JavaScript – no boxes appear there:
- A shortcode shows up in the newsletter as text (
[affilinode_product id="…"]). - A product link stays a normal link – no problem.
- An HTML card with a placeholder stays empty in the newsletter.
Recommendation for posts you send out: place boxes as an HTML card and hide the card in the newsletter. Ghost allows that per HTML card: click the card, open the eye (visibility) in the toolbar and switch Email off – the card then only appears on the web. Ordinary paragraphs cannot be hidden this way, so use shortcodes in paragraphs only in posts that are not sent as a newsletter. A product link in the text is a good choice for both: on the web it becomes a box, in the email it stays a link (but without your tracking ID – if in doubt, use your own affiliate link right away).
Privacy and cookie banners
- The script sets no cookies and stores nothing in the browser (no local storage); all requests are made without
cookies (
credentials: 'omit'). - Only the product identifiers, the link addresses (converting links) or title, headings and the beginning of the post together with the page address without parameters (context box) are sent – no visitor data. affilinode stores neither links nor texts.
- affilinode only counts clicks and visibility as daily totals per layout, without any reader identifier.
- As with any externally loaded script, the reader's IP address reaches affilinode's server (
api.affilinode.com). Mention this in your privacy policy. As we understand it the script does not need a cookie banner – check this for your site yourself or with your legal adviser.
Advertising disclosure
Every box carries the label Ad and an affiliate notice. Still point out affiliate links in the post itself, as you normally would – for example with a sentence at the beginning of the post.
Limits
- The boxes are created in the browser. Search engines without JavaScript, RSS readers and newsletters see the original text or link.
- In the Ghost editor you see shortcodes and placeholders, not the boxes.
- The boxes only appear on the allowed domains. If you see empty spots, check in the dashboard under Embedding →
"Rejected domains" whether, for example, the
…ghost.ioaddress is missing.
6. For theme developers: partial instead of code injection
If you maintain your own theme (or sell themes), you can build the embed into the theme. Blog owners then set it up under Settings → Design & branding → Customize – no code at all.
- Copy
partials/affilinode.hbsinto the theme aspartials/affilinode.hbs. - In
default.hbsadd{{> "affilinode"}}right before{{ghost_foot}}. - Copy the entries from
theme-settings.example.en.json(English labels) ortheme-settings.example.json(German labels) into the theme'spackage.jsonunderconfig.custom. Ghost allows at most 20 custom settings per theme; the template needs five (affilinode_keyastext,affilinode_shortcodesasboolean,affilinode_links,affilinode_contextandaffilinode_themeasselect). - Upload the theme; Ghost checks it with gscan.
Without a key the partial outputs nothing. Shortcodes and links work on posts and pages, the context box on posts only. Use the partial or code injection – not both.
The wizard in the dashboard (Integrations → Ghost, step "Blog") creates the key for affilinode_key; you then skip
the step "Install". "Check installation" recognises the partial as well.
Try it without a key
The public key demo works on any domain and returns made-up products (links to example.com, no commission), e.g.:
[affilinode_product id="nw-x5"]
[affilinode_compare ids=nw-x5,lm-pixel-s]
https://www.amazon.de/dp/B0DEMONWX5
example/index.html is a ready-made test page in Ghost markup with all cases (shortcode in a paragraph and in a
sentence, link alone and in a sentence, quote, code, HTML card, bookmark card, paywall notice) – instructions at the
top of the file.
More
- Dashboard → Integrations → Ghost: wizard with preview and "Check installation"
- Help centre in the dashboard: "Connect a Ghost blog" and "Embed product boxes without WordPress"
Changelog
- 1.0.0 – First public release: guide in German and English, MIT license, theme settings also with English labels,
release ZIP
affilinode-ghost-<version>.zip.
Build a release ZIP
sh build-zip.sh (in this module's folder) writes dist/affilinode-ghost-<version>.zip with the folder
affilinode-ghost/ – without tests and hidden files. Raise the version in package.json first.