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

推荐订阅源

博客园_首页
J
Java Code Geeks
博客园 - 聂微东
量子位
C
Check Point Blog
T
The Blog of Author Tim Ferriss
T
Tailwind CSS Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
B
Blog
罗磊的独立博客
腾讯CDC
GbyAI
GbyAI
博客园 - 【当耐特】
A
About on SuperTechFans
M
MIT News - Artificial intelligence
U
Unit 42
D
Docker
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Y
Y Combinator Blog
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
S
SegmentFault 最新的问题
有赞技术团队
有赞技术团队

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
Ghost CMS News: Native Search
Bright Themes · 2022-07-14 · via Example blog

The Ghost team released one of the most requested features since the platform was launched: a built-in native search function. The search works with all Ghost themes, giving your readers easy access to search all published posts, tags, and authors on your site.

The official Ghost themes were updated and now include this new feature, but even if you are using a custom theme, you can easily add the feature to your site.

Adding the search function

As mentioned, if you are using your own theme, a customized official theme or a premium theme without the search function, you can still add the new native search.

There are two ways:

  1. Add the search with a link (#/search)
  2. Add the search with the data attribute (data-ghost-search)

The easiest way to start is using the link, for this you don't have to change the themes files. You can simply add a link in navigation pointing to the #/search. The label can be 'Search' or even an emoji (🔎).

The other way is using the data attribute, this means you have to edit the theme files, but the advantage is you can place the search trigger element wherever you want. You can add the attribute data-ghost-search to any element, but ideally it should be a button, for example:

<button class="search" data-ghost-search>{{> icons/search}}</button>

You can place this element in the header or in any other place you want, and when clicked it will open the search popup.

Note

You can open the search UI directly by using the Ctrl/Cmd + K keyboard shortcut

Technical details & limitations

Taxonomies for tags and authors must be present for search results to include tags and authors.

There are a few limitations for the native search function:

  • the search feature does not index post content, the search is performed based on post titles, excerpts, authors and tags -to avoid performance issues, the search function can only index 10,000 posts (most recent posts)

For larger sites (more than 10,000 posts) it's recommended to use an advanced search functionality like Algolia.

Conclusions

The new native search is a great addition to the Ghost platform and although it's limited, there are plans to improve it in the next iterations. Overall it's an easy way to provide users the possibility to find what they're looking for with a single click.

If you are looking for alternatives check the post about Ghost search options.