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

How to use pagefind for a non-static website #689

Open
mattiasJohnson opened this issue Aug 27, 2024 · 1 comment
Open

How to use pagefind for a non-static website #689

mattiasJohnson opened this issue Aug 27, 2024 · 1 comment

Comments

@mattiasJohnson
Copy link

mattiasJohnson commented Aug 27, 2024

I would like to include pagefind for an older website which is not static but is using ASP.NET MVC. During the build process of the website I would have no problem generating a folder structure which would be like a static version of the website to use for the indexing. The problem would be to ensure that the links in the search results lead to the actual pages and not to these static files (which I would prefer not to even have to host, just use during build process).

Could someone give some pointers on what I would need to change to have the search results lead to the correct page? (they would of course have the same naming structure so a search result for a static file /documentation/apishould lead to mywebsite.com/documentation/api)

@bglw
Copy link
Contributor

bglw commented Aug 27, 2024

Hi @mattiasJohnson 👋

That setup should just work. Pagefind operates on absolute URLs generally, which means:

  • If pointed at a folder of static files named static, containing a about/index.html file (so static/about/index.html in full)
    • Pagefind will assign that file the URL /about/
  • If that search index is then hosted on https://example.com/ and a search result returns that page
    • Pagefind will output the URL as /about/

In other words, when indexing, all URLs are indexed as absolute URLs relative to the input folder. When searching, the default assumption is that those URLs exist on the current website.

Hopefully that helps explain things — let me know if you're seeing something different, though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants