惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Application and Cybersecurity Blog
Application and Cybersecurity Blog
A
About on SuperTechFans
S
SegmentFault 最新的问题
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Help Net Security
Help Net Security
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
O
OpenAI News
美团技术团队
月光博客
月光博客
Apple Machine Learning Research
Apple Machine Learning Research
Schneier on Security
Schneier on Security
Webroot Blog
Webroot Blog
Cyberwarzone
Cyberwarzone
Hacker News - Newest:
Hacker News - Newest: "LLM"
Google Online Security Blog
Google Online Security Blog
T
Tenable Blog
S
Security Affairs
博客园_首页
S
Schneier on Security
Security Latest
Security Latest
T
Threat Research - Cisco Blogs
T
Tailwind CSS Blog
大猫的无限游戏
大猫的无限游戏
Spread Privacy
Spread Privacy
量子位
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
K
Kaspersky official blog
Hugging Face - Blog
Hugging Face - Blog
TaoSecurity Blog
TaoSecurity Blog
博客园 - 聂微东
Vercel News
Vercel News
M
MIT News - Artificial intelligence
T
Troy Hunt's Blog
B
Blog
MongoDB | Blog
MongoDB | Blog
Martin Fowler
Martin Fowler
Attack and Defense Labs
Attack and Defense Labs
L
LINUX DO - 最新话题
D
DataBreaches.Net
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Stack Overflow Blog
Stack Overflow Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
博客园 - Franky
W
WeLiveSecurity
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
F
Fortinet All Blogs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Check Point Blog
H
Hacker News: Front Page

Example blog

Ghost routing explained with routes.yaml examples — routes, collections & taxonomies Ghost redirects explained with practical redirects.yaml examples How to Serve JSON or XML Data in Ghost How to Change Your Default Post Template in Ghost Ghost Custom Theme Settings How to add Google Fonts to Ghost Themes How to Configure Ghost with Mailgun Ghost Theme Structure & Organization How to Make Custom Templates in Ghost Themes How to Install Ghost CMS via Ghost-CLI How to Add Syntax Highlighting to Ghost The best Ghost CMS hosting platforms Ghost 6.0 — Social Web and Native Ghost Analytics Ghost CMS Social web beta, email 2FA and more author social links How to keep custom design settings when updating your Ghost theme How to use the public preview card in Ghost How to add members-specific sections in Ghost How to customize the default content CTA in Ghost How to build a custom homepage in Ghost An overview of Ghost editor cards and and how they work Ghost CMS News: One-time payments & collecting sales tax How to customize the private site access template in Ghost How to add custom fonts in Ghost themes Ghost CMS News: Additional payment methods & internal linking How to use Code Injection in Ghost How to set meta data of your custom routes & collections in Ghost Ghost CMS News: TK reminders, ActivityPub and improvements How to format dates and use the date helper in Ghost Ghost CMS internationalization, custom fonts & spam protection Understanding and optimizing post and page settings in Ghost CMS Trigger the Ghost Portal popup based on page scroll progress How to Deploy Your Ghost Theme with GitHub Actions Ghost CMS News: New editor, refreshed settings & recommendations Ghost CMS News: Source - the new default theme and native image editing How to Add Different Logos for Dark & Light Themes in Ghost Upgrade to Node v18 for Ghost CMS & common errors Ghost Snippets: Adding Schema markup in Ghost How to add a scroll-based progress bar to your Ghost CMS site How to Create a Custom Navigation Template in Ghost How to Segment Subscribers with Member Labels in Ghost The best way to create a contact page in Ghost How to Use the Ghost Subscription Forms in Your Theme & Posts How to update your Ghost site URL when self-hosting Ghost CMS News: Signup cards and better landing pages How to Add Breadcrumbs to Your Ghost Theme How to integrate the Applause Button into your Ghost theme How to Hide a Post From the Home Page in Ghost CMS Ghost CMS block and contentFor helper overview & tips How to add Image Lightbox to Ghost Themes Ghost CMS News: Signup form embed, new editor and bulk actions. Biron Themes becomes Bright Themes 🎉 How to Audit & Test a Ghost Theme How to Create Related Posts Section in Ghost How to Use Ghost Filter Expressions Ghost CMS newsletter settings and post analytics How to Update Your Ghost Theme When We Release New Versions Ghost CMS News: Automatic list cleaning & email troubleshooting How to Create a Featured Post Slider in Ghost How to Add Reading Time to Ghost Blog Posts How to Create a Post Archive for Your Ghost Theme Ghost CMS Price Helper Overview & Tips Self-Hosted Ghost CMS with DigitalOcean Ghost CMS News: Member Growth Sources & Audience Feedback How to Open External Links in a New Tab in Ghost How to Integrate Google Analytics with Ghost Ghost CMS News: History Log & Newsletter Analytics How to Automatically Add Member Labels From Referral Traffic in Ghost? Ghost CMS News: Free trials & email notifications Ghost CMS Match Helper Usage & Tips Ghost CMS News: Native Comments Ghost CMS News: Ghost Explore & Premium Newsletter Previews Ghost Snippets: Custom Progress Cards & Steps Ghost CMS News: Native Search The Best Ghost CMS Search Plugins & Libraries Ghost Snippets: Custom Stylish Tables How to Add a Scroll Top & Progress Indicator Button in Ghost Ghost Snippets: Accordions How to Add Tag Dropdown to Your Ghost Theme Ghost 5.0 released 🎉 Ghost Snippets: Custom Subscribe Forms Ghost Snippets: Custom Alert Boxes How to Show Post or Newsletter Issue Number in Ghost How to Self-Host Google Fonts in Ghost CMS Ghost CMS News: Membership, Tiers & Activity Feed Custom Pages in Ghost CMS Themes Ghost CMS Search Using Fuse.js Ghost CMS News: Offers and Discounts & New Cards Ghost CMS News: Membership tiers, email CTA & filters Ghost CMS News: Grammarly Support & Feature Image Captions. Ghost CMS News: Improved Member Accounts & Personalized Newsletter. Ghost 4.0 Launched With Native Newsletters & Membership Ghost CMS News: Cancellation Feedback & Newsletter Stats. Ghost CMS News: Improved Member Dashboard & Sidebar Views. Ghost CMS News: Google Pay support, email newsletters & secondary navigation Ghost CMS News: Member Support, Portal & Content Snippets. Ghost CMS News: Referral Programs & Responsive Images. Ghost Themes as Progressive Web Apps Ghost 3.0 is here with brand new features Ghost 2.0 is here with new features How to Add Search to Ghost Using ghostHunter
How to create a custom recommendations page for your Ghost CMS theme
Bright Themes · 2024-01-12 · via Example blog

With the release of version 5.71.0 Ghost added the recommendations feature, publishers can share their favorite sites with their readers and, likewise, be recommended by other publications. Unlike some other platforms Ghost's recommendations system is built to be compatible with any platform, website, or publisher, so you can recommend whoever you like.

How Ghost's recommendations work?

Under the hood, Ghost's recommendations feature is built on the Webmention open standard, which means recommendations aren't limited to any single platform — but extend to every site on the web.

Recommendations also make it possible for readers to subscribe to recommended publications with a single click. This feature is currently exclusive to Ghost sites, but it's possibly going to be possible to integrate it with other platforms too.

Here are some key things happening:

  1. In Ghost, the recommendations modal is shown automatically whenever a new member subscribes to a Ghost publication. You can see the modal using the link: https://yoursite.com/#/portal/recommendations
  2. Adding a recommendation will trigger a check to see if the recommended site has Webmentions enabled. Ghost only notifies sites about your recommendation if they have a Webmention endpoint that can receive it.
  3. Your site receives recommendations in the same way as described above but as the recipient. Ghost automatically adds a link tag to your publication to inform other sites about your Webmention endpoint. Once the incoming recommendation is verified, it's added to Ghost Admin and you receive a notification.

Built-in recommendations

Ghost comes with all the tools to manage and show your recommendations, you don't have to add anything to your Ghost theme for this.

You can mange your recommendations in the Ghost Admin > Settings > Recommendations (#/settings/recommendations).

You have two tabs:

  • Your recommendations - listing all the sites you have recommended, including the number of clicks each has received
  • Recommending you - list of sites and publications recommending your site

There is also a button to Add recommendation, where you have to provide the URL of the site you want to recommend, any website not just those published on Ghost.

Ghost recommendation settings
Ghost recommendation settings

Additionally, the Ghost Portal was extended to include recommendations, here's the link to access it: #/portal/recommendations

Recommendations in Ghost themes

Recommendations can also be natively integrated into any Ghost theme, for this two new helpers were introduced: {{recommendations}} and {{readable_url}}.

Recommendations helper

The {{recommendations}} helper can be used anywhere in your theme and it will output a list of recommended sites based on the default template provided by Ghost.

Alternatively, you can override the default template altogether with a custom one by adding a file called recommendations.hbs to the theme's /partials/ folder.

The recommendations helper accepts the following attributes:

  • limit - set the maximum number of recommendations to display, the default is 5.
  • order - set the order of recommendations based on any valid resource field, the default order is newest first ()created_at desc)
  • page - when the total number of recommendations exceeds the number defined in limit, recommendations become paginated
  • filter - use logic-based queries to filter recommendations

For more details, check out the official documentation.

Readable url helper

The {{readable_url}} helper outputs a human-readable URL. While this helper was created for the output of recommended sites, it can be used anywhere else where you need it.

What the helper does:

  • removes the protocol (https://)
  • removes www
  • removes query parameters
  • removes hash fragments

It doesn't remove any subdomains or pathnames.

The {{recommendations}} and {{readable_url}} helpers all you need to create your own recommendations section or page.

Custom recommendations page

To create a custom recommendations page, we have to create a custom template with code for rendering recommended sites, assign the template to a route, styling the list. Now let's see each of those in detail.

Create a custom template

Create a new file in the root directory of your theme, for example: recommend.hbs The template needs a few parts:

  • {{!< default>}} to inherit from your default template
  • a page title
  • the recommendations

Here's what the file would look like:

{{!< default}}

{{#page}}
  <h1 class="page-title">{{t "Recommendations"}}</h1>
{{/page}}

{{recommendations}}

This would render the recommendations using the default Ghost template, if you want to define your own markup and css classes create the recommendations.hbs file in the /partials/ directory.

Create the route

Now that the template is ready, we have to create a new route. For this we have to add a new entry in the routes.yaml file, under the routes: section:

  /recommendations/:
    template: recommend

This creates the /recommendations/ route and sets our recommend.hbs file as the template.

Note

If you are using Ghost locally, don't forget to restart Ghost.

Styling the recommendations

As mentioned already, you can overwrite the default recommendations template, in which case you can define your own CSS classes (ideal for something like Tailwind), this is what we did for the Bokeh theme, here's the demo.

If you are using the default Ghost template, there are a few CSS classes to target:

  • recommendations - the <ul> element class
  • recommendation - the <li> element class
  • recommendation-favicon - the favicon class (has in <img> inside)
  • recommendation-title - the title element class (<h5>)
  • recommendation-url - the url element class (<span>)
  • recommendation-description - the description element class (<p>)

You can integrate the styles in your theme's assets or alternatively add the them in Code Injection:

<style>
.recommendations {
  /* Add your styling for the recommendations list */
}

.recommendation {
  /* Styling for individual recommendation */
}

.recommendation-title {
  /* Styling for the recommendation title */
}

.recommendation-favicon {
  /* Styling for the recommendation favicon */
}

.recommendation-url {
  /* Styling for the recommendation url */
}

.recommendation-description {
  /* Styling for the recommendation description */
}
</style>

Styles are not included here, but you have all the steps to create a custom recommendations page.


In conclusion, the new recommendations feature in Ghost offers publishers a powerful tool to engage with readers and discover new sites. Recommendations extend beyond the Ghost platform, making it compatible with any website or publisher.

With easy management in Ghost Admin, integration into Ghost themes, and the possibility of custom recommendations pages, publishers have the flexibility to tailor the feature to their needs.

Whether you want to share your favorite sites or receive recommendations for your publication, Ghost's recommendations feature provides a seamless and efficient solution.