solvit.io

Define an OpenSearch XML document to describe the search engine of your website

Solution #1

Step 1. Create a open-search.xml file with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
    <ShortName>Example.org</ShortName>
    <Description>Lorem Ipsum Dolor Sit Amet.</Description>
    <Url type="text/html" template="http://example.org/?q={searchTerms}"/>
</OpenSearchDescription>

This XML file has three mandatory elements:

  • ShortName: 16 or fewer characters of plain text.
  • Description: 1024 or fewer characters of plain text.
  • Url: describes how a client (a person, a browser, a search engine) looks for resources on your website. The type and template attributes are required:
    • type: is the MIME type of the returned contents (text/html for web pages).
    • template: is the URL used to search contents on your website. The placeholder {searchTerms} refers to the user's search query (see the OpenSearch URL template syntax).

Step 2. Add a link to that document in every page of your website:

<!-- ... -->
<head>
    <!-- ... -->
    <link rel="search" href="/open-search.xml" title="Search Example.org"
          type="application/opensearchdescription+xml">
</head>
<!-- ... -->
Solution #2

The OpenSearch Specification defines a detailed XML description document for more complex websites.

Find more solutions about: , , , , , ,