Permalink to Discourse search

(Dan Fabulich) #1

We’re importing a Vanilla forum to Discourse; as part of this migration, I’m writing a PHP script to 301 redirect old Vanilla URLs to new Discourse URLs. I’ve got most of them hooked up properly, but I’m having trouble with search URLs. I don’t see a way to 301 redirect a user to a Discourse search result.

Search results for ‘’ - Discourse Meta returns “200 OK” but displays a 404-ish error message, “The page you requested doesn’t exist or is private.” (That seems like a “soft 404,” a bug.)

How, if at all, can I link to a Discourse search result page?

(Ben T) #2

There currently is no separate page for search, as the drop down at the top is the only user facing search mechanism. You could direct out to a google site search (see the 404 page for an example), or add in a route that populates the search bar.

(Dan Fabulich) #3

Walk me through this from an end user perspective. I guess I’d link to Search results for ‘’ - Discourse Meta, but that’s not what the URL bar would show, right? Would it do a redirect/replaceState to the root of the forum? But then open the populated search bar to show results?

(Salman, Freelance Developer) #4

That seems like a big limitation to me, although I like how it currently works UX wise but directly linking to a search is a good thing to have.

@dfabulich Your best bet might be creating a new standalone page if you have allot of pages indexed in google for this or rely on this type of feature e.g. members may have links inside of posts that are linking to search result pages.

(Dan Fabulich) #5

That does seem like the best way, but it sounds like it may be too big of a feature for my first engagement with Discourse code.

(Salman, Freelance Developer) #6

I understand. If you are pressed for time you could create a non-ember.js page and just call the search routine and display the results (until you get a proper solution in place).

(Sam Saffron) #7

We don’t have a dedicated search page, it’s on our roadmap possibly in the next few months

Best practices for URL forwarding/rewriting from a previous (non-Discourse) system
(Lindsey Meyer) #8

We’d love to implement this on our Discourse. Any updates on this?

(Sam Saffron) #9

Dedicated search page is on my task list some time in the next 30-60 days

(Fletcher) #10

Echoing @lindsey, any updates on this?

(Jeff Atwood) #11

No, this may be pushed back due to necessary infrastructure work (sysadmin technical debt). We need to have sites up and running and accessible for full page search to be relevant…

(Dan Dascalescu) #12

A search results page would greatly help with migrating other forums to Discourse by redirecting old URLs to searches for keywords in the post title.

(Sam Saffron) #13

This now works:

(Sam Saffron) #14

(Jeff Atwood) #15

Do we block the /search path via robots.txt? We better…

(Sam Saffron) #16


Disallow: /search
Disallow: /search/