Search page in blog

Hi!

First of all, as usual, my apologies if this has been covered before.
I did find some posts in here on search boxes, but nothing I could really use with my basic skills.

Is there a guide on how to implement a search feature in blogs in write.as, that does not use google services?
Something like this: https://search.cjeller.site/

Or, if no notes exist, is there a good, patient soul willing to help me implement this?

Thanks!

Hi @Melyanna!

I was able to remix the search app I use for my blog into something like this that uses your theme and searches your blog. What do you think? All you would need to do is pin a placeholder post (like https://blog.melyanna.net/search for example) and add the following JavaScript to the Custom JavaScript on your Customize page:

const search = document.querySelector('a[href*="https://blog.melyanna.net/search"]');
pinned.href = 'https://bejewled-stocking.glitch.me/';

Hope that helps! Would be glad to help further.

3 Likes

EDIT: well, actually, while it does look amazing, I gave this a try on my blog and I don’t see a search box in the search page.

What I did:

  1. copy-paste your code and put it in the custom js box of my blog.
  2. added a “Search” page and pinned it.
  3. hit save.

All I could see was the bunch of text I had in the search page (“you can search this blog for specific words”) and nothing else.

I don’t think I can make an empty page with just a title (in case the text in the body of the page is the issue).

It was nothing on your end @Melyanna. I goofed up with the JavaScript! Here is the edited code:

const search = document.querySelector('a[href*="https://blog.melyanna.net/search"]');
search.href = 'https://bejewled-stocking.glitch.me/';

I forgot to make it search.href and instead had it as pinned.href. So since no variable is declared in the JS as “pinned”, nothing happens.

Let me know if that works for you!

3 Likes

Thank you so much!
It works perfectly now. :slight_smile:

1 Like

No problem! I am glad it’s finally working for you. Let me know if you need any edits to it and I can gladly do so.

1 Like