How to create Sitelinks Search Box markup?

Modified on Thu, 20 Apr 2023 at 10:13 AM

By implementing Website and Search Action markup, your content can be made eligible for Google's Sitelinks Search Box feature. 


How to create Sitelinks Search Box markup



Step 1: Create a Website data item

  • Fill out the name and URL properties for the Website data item (the name should match the name of the Website)
  • use the potentialAction property to create a SearchAction data item


Step 2: Create a SearchAction data item

  • Fill out the name property on the SearchAction data item (the name can be anything, but should be easily identifiable in a list of data items)


Step 3: Find the URL template

  • The URL template is the base URL used for searching across your website. To find it:
    1. Search for any term on the site, in this case we're searching for "FAQ" on Schemaapp.com

    2. Copy the base URL before the term, in this case we're copying "https://www.schemaapp.com/?s=" but leaving out the "FAQ" because that will be replaced by a variable.


    3. Append the URL with a variable that will be replaced with whatever search term a user may enter. Wrap the variable in curly brackets. For example, {search_term_string}.

    4. Paste the base URL + variable in the target property of the SearchAction. In our example, the full value for "target" is "https://www.schemaapp.com/?s={search_term_string}"


Note: You only need to paste text into the target property. Google will automatically transform this value into an EntryPoint data item.


Step 4: Provide the query-input

  • The SearchAction's query-input value must match the variable you provided for the target without the curly brackets and in this format: "required name=target_value". In our example that would be "required name=search_term_string".
Note: You only need to paste text into the query-input property. Google will automatically transform this value into a PropertyValueSpecification data item.
  • Leave the "query" property blank. Google will fill this out based on the rest of the schema you have provided.

Step 5: Check your work

  • Validate your structured data using the Schema Validator and/or Rich Results test and make any necessary adjustments. To verify the work that you’ve done, use the testing tools withing the Editor, or select "View JSON-LD", then copy the markup and input it as code into Google’s Rich Results Tool.




Here is an example of what the JSON-LD might look like:


<script type="application/ld+json">

{

    "@context": "http://schema.org",

    "@type": "WebSite",

    "potentialAction": {

        "@type": "SearchAction",

        "target": "https://www.example.com/search?q={search_term_string}",

        "name": "Search Example Site",

        "query-input": "required name=search_term_string",

        "@id": "https://www.example.com/#SearchAction"

    },

    "url": "https://www.example.com/",

    "name": "Example Website",

    "@id": "https://www.example.com/#WebSite"

}

</script>


Here is an example of what your search action data item will look like in the editor:


Note: If your site is on Wordpress, the Schema App plugin can automatically generate Sitelinks Search Box markup.





Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article