pagefind icon indicating copy to clipboard operation
pagefind copied to clipboard

How to override URLs?

Open geoffroy-noel-ddh opened this issue 1 year ago • 1 comments

I've followed the instructions on how to override page urls but the search results appear unaffected.

Steps to reproduce

Create index.html under a new folder called site:

<!DOCTYPE html>
<html lang="en">
<head>
        <meta charset="utf-8">
        <title>Page title</title>
        <link data-pagefind-meta="url[href]" rel="canonical" href="https://example.com/other-url">
</head>
<body>
 <h1>title 1</h1>
 <p>A simple sentence to be indexed.</p>
</body>
</html>

Add a search page under site/search.html:

<html>
<body>
<link href="/pagefind/pagefind-ui.css" rel="stylesheet">
<script src="/pagefind/pagefind-ui.js"></script>
<div id="search"></div>
<script>
    window.addEventListener('DOMContentLoaded', (event) => {
        new PagefindUI({ element: "#search", showSubResults: true });
    });
</script>
</body>
</html>

Index and serve with pagefind 1.1.0:

npx pagefind --site site --serve

Point your browser to localhost:1414/search.html.

Search for 'sent'

The correct result appears:

image

However that hyperlink points to http://localhost:1414/ .

Instead, according to the documentation, I was expecting the URL to be https://example.com/other-url .

Did I misunderstand or forget something or made a mistake? Or is that a bug?

Thanks in advance for the assistance.

geoffroy-noel-ddh avatar Aug 22 '24 18:08 geoffroy-noel-ddh

Hey @geoffroy-noel-ddh 👋

Thanks for the great report and reproduction. Yes this is indeed a bug! I'll get it fixed up.

bglw avatar Aug 27 '24 23:08 bglw