Signed-off-by: DanRoscigno <dan@roscigno.com>
This commit is contained in:
DanRoscigno 2025-04-16 19:27:12 -04:00
parent fa5a30c52c
commit c16ae38a8b
No known key found for this signature in database
GPG key ID: 173762EABBD1ACE4

View file

@ -36,12 +36,65 @@ title: Page name
```
## Configure the Algolia index
Each Algolia index has several configuration options. The section to configure for page boosting is **Index****Configuration****Relevance Essentials****Ranking and Sorting** → **Custom Ranking**
If **`weight.pageRank`** is not in the list of custom ranking attributes, add it with **Add custom ranking attribute**.
## Configure the Algolia Crawler
The Algolia Crawler configuration is edited in your Algolia account. Access the crawler editor from the Algolia dashboard for your Algolia application at **Data sources****Crawler** by choosing the name of the crawler, and then **Editor**.
There are three edits to be made:
### Modify the `recordExtractor` function
:::tip
In the JavaScript snippets the `$` is the Cheerio instance, and allows you to manipulate the `DOM`. Links are in the **More information** section at the end of this doc.
:::
The `recordExtractor` needs access to the Cheerio instance to extract the metadata from the `DOM`.
Verify that the `recordExtractor` function includes the Cheerio instance as a parameter. Your record extractor function may have the `$`, if so you can skip this step. Your record extractor may also have other parameters listed, you should not remove parameters.
```js
recordExtractor: ({ $, helpers }) => {
```
### Extract the `pageBoost` metadata
Within the `recordExtractor` function add the highlighted line to extract the `pageBoost` metadata into `const pageBoost`, with a default value of 0 if no metadata is present in the page.
```js
recordExtractor: ({ $, helpers }) => {
// highlight-start
// Extract metadata
const pageBoost = $("meta[name='pageBoost']").attr("content") || "0";
// highlight-end
```
### Assign the `pageRank`
```js
foo
```
## Testing
![Algolia test URL records](/img/boost/boost_algolia_test_url_records.png)
![Algolia search UI page rank](/img/boost/boost_algolia_page_rank_search_ui.png)
## More information
[Adding metadata](../guides/markdown-features/markdown-features-head-metadata.mdx)
Configuring [Search](../search.mdx)
Algolia Crawler [record extractor](https://docsearch.algolia.com/docs/record-extractor)