firefoxsearchdesktop

How do I add a custom search engine to Firefox desktop?


I want to add a country specific search engine e.g. https://www.google.co.in/search?gl=IN&q=TEST

It used to be possible to edit the search engine config in the profile folder. Firefox Android lets you enter your chosen URL in settings.

I have seen old posts about this but has anyone done this recently.


Solution

  • There are three ways to do this.

    Re-enable a feature from the past

    1. Type in about:config in the address bar. Accept all the scary warnings.
    2. Search for browser.urlbar.update2.engineAliasRefresh.
    3. Press the + (on the right hand side).
    4. Now when you go to Settings > Search, there should be an Add button under the box which lists the various search engines available.
    5. Don't let this post get popular, otherwise this method will also be deprecated to make Firefox better than ever!

    Right click on the URL bar, when it contains a URL with a search query segment

    It also seems to be possible to add a search engine by right-clicking on the URL bar (caveat: only if the search engine has not already been added to the search box using some other URL with the same base):

    1. Go to a website of interest, that allows submitting a search URL. For the sake of example, let's consider: https://crates.io/search?q=firefox
    2. Right click on the URL bar, and you should get an option to add the search engine (if it hasn't already been added before).

    I think the important bit here is the presence of ?q= in the URL string, as it seems to trigger the existence of the menu entry we want.

    Add a search engine as a keyworded bookmark

    There is (sort of) a third way too:

    1. Navigate to a page with a search bar of some sort
    2. right click on the search bar and you should get the option to "add a Keyword for this Search"; click on this
    3. a Bookmarks widget pops up (perhaps confusingly?). This is because Firefox adds the search engine as a Bookmark. You can put in a keyword like @myengine
    4. In a fresh URL bar, enter @myengine (autocomplete when available to ease your life), and then enter a query.
    5. Opening up the Bookmarks manager, and selecting the newly added bookmark, you should see that the associated URL does contain a %s placeholder for the search term.
    6. Which suggests that you may not always need to right-click in order to trigger this, and it may be possible to manually add a bookmark with the appropriate placeholder (%s is the only one I know of so far, but perhaps there are more)?

    This might arguably the be the best method today because Firefox does sync Bookmarks between devices, but it does not bother syncing Search Engines (although, it is possible to manually "sync" by copying the search.json.mozlz4 in the .mozilla user configuration folder (or equivalent on other OS) between machines).