Skip to content

don't understand how to modify pagefind-ui. and how to keep it between reindexing #517

Answered by bglw
evanescente-ondine asked this question in Q&A
Discussion options

You must be logged in to vote

👋 Hey @evanescente-ondine

That JavaScript can go inside one of your existing (non-Pagefind) JavaScript files, or if you have none, within a <script> element anywhere in your HTML.

For example, Pagefind's website uses a Hugo template. Hugo uses the baseof.html layout file to render all pages to the static site, so in this file we insert the PagefindUI JavaScript inside a <script> element:

https://github.com/CloudCannon/alto-hugo-template/blob/14ea7320838fb004d23d49bbf60d557822a0090b/layouts/_default/baseof.html#L71-L75

Putting it inside a window.addEventListener('DOMContentLoaded' ... block ensures that Pagefind's scripts have loaded before this initialization is executed.

This layout also…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@evanescente-ondine
Comment options

Answer selected by evanescente-ondine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #515 on November 28, 2023 22:30.