Weighting sections of the page higher or lower
Content in Pagefind’s index can be ranked higher or lower. These weights will be taken into account when Pagefind ranks your search results, and will also be used when generating excerpts of your content to preview.
Pagefind will boost the
h6 tags above any other content on the page. By default, content is ranked as:
|All other elements||1.0|
#Ranking content higher or lower
You can specify your own ranking via the
<body> <p data-pagefind-weight="2"> The main description text of the page. If the search term matches this section, this page will be boosted higher in the result ranking. </p> <p> Other, less important text. This defaults to a weight of 1. </p> <p data-pagefind-weight="0.5"> Very unimportant text. Matching words in this block are only worth half a normal word. </p> </body>
Custom weights can be set to any number between
Weightings are ranked using a quadratic scale, so a ranking of
2.0 will have roughly 4 times the impact of standard text, and a weighting of
10.0 will have roughly 100 times the impact.