You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a81d8e3
Browse filesBrowse the repository at this point in the historyBrowse files
Update pagefind to align with src/glob in pages config options
* Inject data-pagefind-body when page is searchable
* Remove glob option & logic handling in SiteGenerationManager
* Fix inaccurate no. of page indexed count
Previously, because we used the glob within pagefind's configuration
option which controlled how pagefind discover's HTML files to index, it
would only index the files that we declared within the glob.
But since we now insert data-pagefind-body into the pages that we want
to index, technically pagefind will index all the pages. However, it
still seems to index pages that are not searchable, its just that
nothing on these pages will be searchable, hence creating sort of a
pseudo not indexed page.
Currently, the fix is just to take the count of the number of
addressable pages that are searchable.
* Remove glob processing helper methods
No longer needed since we adding the glob pattern into the pagefind's
index dictionary.
* Update test cases for SiteGenerationManager
* Update docs
* Update functional tests
* Add clearer comments and test cases
* Implement addHTML approach using index dictionary
* Update SiteGenerationManager test cases
* Update functional tests and docs
Docs now clearly document the interactions of searchable with pagefind's
native attributes
Copy file name to clipboardExpand all lines: docs/userGuide/makingTheSiteSearchable.md
+40-16Lines changed: 40 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,34 +101,58 @@ In your `site.json`:
101
101
102
102
This tells Pagefind to exclude any element with the `algolia-no-index` class (or containing it in a space-separated list) from the search index, similar to using `data-pagefind-ignore`.
103
103
104
+
For more details, see the [Pagefind documentation on exclude selector configuration option](https://pagefind.app/docs/config-options/#exclude-selectors).
105
+
104
106
#### Limiting Which Pages Are Searchable
105
107
106
-
You can use the `glob` option to limit which pages are indexed by Pagefind. This is useful when you want search results to only show pages from specific sections of your site.
108
+
Pagefind uses the existing `searchable` property in your `pages` configuration to determine which pages should be indexed. This provides a seamless way to control search indexing without additional configuration.
107
109
108
110
In your `site.json`:
109
111
110
112
```json
111
113
{
112
-
"pagefind": {
113
-
"glob": [
114
-
"devGuide",
115
-
"userGuide/*"
116
-
]
117
-
}
114
+
"pages": [
115
+
{
116
+
"src": "index.md"
117
+
},
118
+
{
119
+
"src": "internal/notes.md",
120
+
"searchable": "no"
121
+
},
122
+
{
123
+
"glob": "devGuide/**/*.md",
124
+
"searchable": "no"
125
+
}
126
+
]
118
127
}
119
128
```
120
129
121
-
MarkBind supports glob patterns and will automatically append `.html` to your patterns if not specified. For example:
- Pages with `searchable: "no"` (or `false`) will not appear in search results
131
+
- By default, all pages are searchable (`searchable: "yes"`)
132
+
133
+
For more details on the `searchable` property, see [site.json file documentation](siteJsonFile.html#pages).
134
+
135
+
<panelheader="Interaction with Pagefind Attributes">
136
+
137
+
MarkBind controls page indexing through the `searchable` property, which determines whether pages are passed to Pagefind for indexing. However, Pagefind also provides native attributes that can affect indexing:
126
138
127
-
Only pages matching these glob patterns will appear in search results. This can be particularly useful for:
128
-
- Multi-site setups where you want to search only specific sections
129
-
- Including only certain directories from search results
139
+
-[**`data-pagefind-body`**](https://pagefind.app/docs/indexing/#limiting-what-sections-of-a-page-are-indexed): Marks a specific element as the search content container. When this attribute exists on ANY page of your site, pages WITHOUT this attribute will not be indexed.
140
+
-[**`data-pagefind-ignore`**](https://pagefind.app/docs/indexing/#removing-individual-elements-from-the-index): Excludes specific elements from the search index.
130
141
131
-
For more details on glob patterns, see the [Pagefind documentation](https://pagefind.app/docs/config-options/#glob).
142
+
**How MarkBind handles this:**
143
+
144
+
1. Pages with `searchable: "no"` are NOT passed to Pagefind at all (they are never indexed).
145
+
2. Pages with `searchable: "yes"` (default) ARE passed to Pagefind for indexing.
146
+
147
+
**Interactions to be aware of:**
148
+
149
+
- If you add `data-pagefind-body` to a searchable page, it works as expected - the page is indexed. However, only pages with this attribute will be searchable.
150
+
- If you add `data-pagefind-body` to a non-searchable page, MarkBind will still NOT index it (because it's filtered before being passed to Pagefind).
151
+
- Adding `data-pagefind-ignore` to a searchable page will NOT prevent it from being indexed - the page is still added via MarkBind's indexing, but the content within that element will be ignored by Pagefind.
152
+
153
+
**Recommendation:** Use MarkBind's `searchable` property in site.json to control which pages are indexed & use `data-pagefind-body` attribute to exlcude specific elements within a page from being searchable. Avoid using `data-pagefind-body` as it is redundant and may lead to confusion.
Copy file name to clipboardExpand all lines: docs/userGuide/siteJsonFile.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -135,7 +135,7 @@ _(Optional)_ **The styling options to be applied to the site.** This includes:
135
135
***`globExclude`**: An array of file patterns to be excluded from rendering when using `glob`, also defined in the glob syntax.
136
136
***`title`**: The page `<title>` for the generated web page. Titles specified here take priority over titles specified in the [frontmatter](tweakingThePageStructure.html#frontmatter) of individual pages.
137
137
***`layout`**: The [layout](tweakingThePageStructure.html#layouts) to be used by the page. Default: `default`.
138
-
***`searchable`**: Specifies that the page(s) should be excluded from searching. Default: `yes`.
138
+
***`searchable`**: Specifies whether the page(s) should be included in search indexing. This applies to both the built-in search and Pagefind (if enabled). Set to `"no"` or `false` to exclude the page(s) from search results. Default: `yes`.
139
139
***`externalScripts`**: An array of external scripts to be referenced on the page. Scripts referenced will be run before the layout script.
140
140
***`frontmatter`**: Specifies properties to add to the frontmatter of a page or glob of pages. Overrides any existing properties if they have the same name, and overrides any frontmatter properties specified in `globalOverride`.
141
141
***`fileExtension`**: A string that specifies the output file extension (e.g., `".json"`, `".txt"`) for the generated file. If not specified, defaults to `".html"`. Note that non-HTML files do not support frontmatter or scripts.
0 commit comments