Pagefind

hello,

I’m trying to exclude tags’s name and categories’s name from the results of “pagefind”.

What I have to do ? Please

what did you try? what do you have already?

see Requesting Help

I use pagefind normally :

npx -y pagefind --site public --serve

with this code : View paste 5AAA

And for example, when I search “linux”, I get taxonomies’s name and sections’s name.
But i don’t want this (category,tag,section)

I want only results from title and summary of posts

you will have to customize the layouts for these pages and add the data-pagefind-ignore to it. Check out the other options there. data-pagefind-body provides an opt-in for the index

hello

look this img, there are categories and tags in result, i want only posts

sorry for maybe being unclear.

you will have to tell pagefind to skip unwanted text from indexing. That is done by generating additional data-pagefind attributes to the target html files by adjusting the template code.

withou that pagefind will index every pages body content.

sorry I get it, it’s ok now, thanks a lot

you can also restrict indexed pages using the CLI using --glob or in the config file.

pagefind --site public --glob 'posts/**/*.html' will only index pages from posts.

If your templates add a list of tags to the post pages, than you just have additionally add data-pagefind-ignore="all"to your single pages layout to the outermost html element containing your tag list.

plenty of possibilities to choose from depending on your personal site setup.

1 Like

The best way is to add data-pagefind-body to the h1 in single.html and in the <article> wrapper for the {{ .Content }}

<h1 data-pagefind-body>{{ .Title}}</h1>
<article data-pagefind-body>
  {{ .Content }}
</article>

At least that works for me.

As I said:

Your’s will effectively ONLY index <h1> and <article> content.

  • If you have other tags outside these won’t
  • If you have a tag list inside the article it will be indexed.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.