Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for pagefind #5034

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _includes/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
{% include_cached search/google-search-scripts.html %}
{%- when "algolia" -%}
{% include_cached search/algolia-search-scripts.html %}
{%- when "pagefind" -%}
{% include_cached search/pagefind-search-scripts.html %}
{%- endcase -%}
{% endif %}

Expand Down
2 changes: 2 additions & 0 deletions _includes/search/pagefind-search-scripts.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<link href="{{ "/pagefind/pagefind-ui.css" | relative_url }}" rel="stylesheet">
<script src="{{ "/pagefind/pagefind-ui.js" | relative_url }}"></script>
7 changes: 7 additions & 0 deletions _includes/search/search_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,12 @@
{%- when "algolia" -%}
<div class="search-searchbar"></div>
<div class="search-hits"></div>
{%- when "pagefind" -%}
<div id="search"></div>
<script>
window.addEventListener('DOMContentLoaded', (event) => {
new PagefindUI({ element: "#search", showSubResults: true });
});
</script>
{%- endcase -%}
</div>
12 changes: 12 additions & 0 deletions docs/_docs/05-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,18 @@ Add a Google search box to your site.
**Note:** If your site is new and hasn't been indexed by Google yet, search will be incomplete and won't provide accurate results.
{: .notice--info}

#### Pagefind from Cloudcannon

You can use [Pagefind](https://pagefind.app/) to add search for you static site also.

First you build your site like normal, and then afterwards you run the following command.

```bash
npx -y pagefind --site public
```

It is important that you run the script after you have build your site (and everytime you rebuild). You can read more in the [Pagefind docs](https://pagefind.app/docs/).

### SEO, social sharing, and analytics settings

All optional, but a good idea to take the time setting up to improve SEO and links shared from the site.
Expand Down