Ghost Inline Stocks: add stock quotes to Ghost posts
When a post mentions Apple’s stock symbol, $AAPL, readers may want to see its price. Ghost Inline Stocks adds a small quote beside the symbol. It shows a price in US dollars and a percentage change within the paragraph.
I made this free script so you can add the feature to your Ghost theme without editing theme files.
I also include this feature in two of my Ghost themes: Siwa and Taba. If you use either, follow its own guide: Siwa or Taba.
Get a Finnhub key
The script is free. Its quotes come from Finnhub. You need a Finnhub account and an API key. This code lets the script request quotes.
- Create or log in to your Finnhub account.
- Open the Finnhub dashboard.
- Copy your API key.
Check Finnhub’s current plans and limits. Check which stocks you can access and whether you may publish their quotes. Then choose one of the two setup options below.
Choose a setup
Complete one of the two options below, then continue to Add the Script.
Direct setup
This is the quickest option. Anyone who views your site’s code can see your Finnhub key.
- In Ghost, open Settings → Advanced → Code Injection.
- Paste this snippet into Site Header.
- Replace
YOUR_FINNHUB_KEYwith your key. - Select Save.
<script>
window.finnhubApiKey = 'YOUR_FINNHUB_KEY';
</script>
Cloudflare setup (recommended)
This option keeps your Finnhub key in your Cloudflare account, out of your site’s code. You need a Cloudflare account and your Finnhub API key. Your website can stay on its current host.
- Open the stock ticker setup.
- Connect your Cloudflare account.
- Enter your website address and Finnhub API key.
- Copy the snippet shown during setup.
- In Ghost, paste it into Settings → Advanced → Code Injection → Site Header.
- Select Save.
If you switch from direct setup, remove the direct-key snippet. To add a site or update your key, run setup again with the same Cloudflare account.
Add the script
After completing either setup option, paste this into Site Footer and select Save:
<script
src="https://cdn.jsdelivr.net/gh/aspirethemes/ghost-inline-stocks@main/dist/inline-stocks.min.js"
defer
></script>
The script works on Ghost posts. It leaves the homepage, tag pages, author pages, and regular pages unchanged.
Check a post
Write this in a normal paragraph, then open the post preview or its web page:
Following $AAPL and $MSFT this week.
Each supported symbol should show a price in US dollars. It should also show the percentage change from the last closing price. Quotes load when the post opens. They do not keep updating.
Use uppercase US stock symbols of one to five letters, with a dollar sign before them. Symbols with extra parts, such as $BRK.B or $VOD.L, stay as plain text.
Symbols in headings, links and code blocks stay unchanged. The script adds quotes to the web page. It does not add them to Ghost newsletter emails.
If a symbol stays unchanged:
- Check that you saved the setup snippet in Site Header and the script in Site Footer.
- Check that the symbol is uppercase and appears in a normal paragraph.
- For direct setup, check that you replaced
YOUR_FINNHUB_KEYwith your key. For Cloudflare setup, check your website address. It must match the address readers visit. - Wait a minute and reload. The account may have reached its quote-request limit. Try
$AAPLas well. If it loads but another symbol does not, ask Finnhub support whether your plan covers that symbol.
If quotes still do not appear, contact me. Include your theme name, the post’s address and the stock symbol. Do not include your API key in the message. The original symbol stays readable when a quote cannot load.
Remove the feature
To turn off the feature, delete the Inline Stocks script from Site Footer and save. You can also remove the setup snippet from Site Header, if no other stock feature uses it. Keep any other code in both fields. Your posts still contain the original symbols. You do not need to rewrite your posts.
More from the Blog
Latest Ghost Themes
Arish
For visual magazines that lead with photography, film, and selected stories.
Siwa
A personal publication that introduces the writer before inviting readers into the stories.
Hanoi
An image-led magazine for creative stories, rich navigation, and long-form reading.
Taba
A newsroom front page for coverage across topics, video, and story formats.
Marsa
A flexible publication homepage for featured stories, topics, and newsletters.
Hakone
For writers who want readers to browse complete posts on the homepage.