Can I use a friendly URL on SearchAction?












1















My current URL for searches is this one:



https://example.com/search/key/seach_word_here


JSON-LD



<script type='application/ld+json'>
[
{
"@context":"http://schema.org",
"@type":"WebSite",
"@id":"#website",
"url":"https://example.com",
"name":"Example",
"potentialAction":{
"@type":"SearchAction",
"target":"https:https://example.com/search/key/{search_term_string}",
"query-input":"required name=search_term_string"
}
},

{
"@context":"http://schema.org",
"@type":"Organization",
"url": "https://example.com",
"name": "Example",
"logo":"https://example.com/img/logo.png",
"@id":"#organization",
"sameAs": ["https://www.facebook.com/example"]
}

]
</script>


As you can see I'm using a friendly URL on the target.



I have seen people using a query string on the URL like this:



https://example.com/?search={search_term_string} 


I did not see people using a friendly URL on the target. It's not allowed?



And at https://developers.google.com/search/docs/data-types/sitelinks-searchbox it says:




Verify your search engine implementation by copying the WebSite.potentialAction.target URL from your structured data, replacing search_term_string with a test query, and browsing to that URL in a web browser. For example, if your website is example.com, and you want to test the query "kittens", you would browse to https://www.example.com/search/?q={kittens}.




I tested this url https://example.com/search/hey/{search_word_here} and I got a 404 not found, but this URL worked: https://example.com/?p=search&tp=key&word={search_word_here}.



So my question is: Can I use a friendly URL on the target? And the code on my snippet is correct?










share|improve this question





























    1















    My current URL for searches is this one:



    https://example.com/search/key/seach_word_here


    JSON-LD



    <script type='application/ld+json'>
    [
    {
    "@context":"http://schema.org",
    "@type":"WebSite",
    "@id":"#website",
    "url":"https://example.com",
    "name":"Example",
    "potentialAction":{
    "@type":"SearchAction",
    "target":"https:https://example.com/search/key/{search_term_string}",
    "query-input":"required name=search_term_string"
    }
    },

    {
    "@context":"http://schema.org",
    "@type":"Organization",
    "url": "https://example.com",
    "name": "Example",
    "logo":"https://example.com/img/logo.png",
    "@id":"#organization",
    "sameAs": ["https://www.facebook.com/example"]
    }

    ]
    </script>


    As you can see I'm using a friendly URL on the target.



    I have seen people using a query string on the URL like this:



    https://example.com/?search={search_term_string} 


    I did not see people using a friendly URL on the target. It's not allowed?



    And at https://developers.google.com/search/docs/data-types/sitelinks-searchbox it says:




    Verify your search engine implementation by copying the WebSite.potentialAction.target URL from your structured data, replacing search_term_string with a test query, and browsing to that URL in a web browser. For example, if your website is example.com, and you want to test the query "kittens", you would browse to https://www.example.com/search/?q={kittens}.




    I tested this url https://example.com/search/hey/{search_word_here} and I got a 404 not found, but this URL worked: https://example.com/?p=search&tp=key&word={search_word_here}.



    So my question is: Can I use a friendly URL on the target? And the code on my snippet is correct?










    share|improve this question



























      1












      1








      1








      My current URL for searches is this one:



      https://example.com/search/key/seach_word_here


      JSON-LD



      <script type='application/ld+json'>
      [
      {
      "@context":"http://schema.org",
      "@type":"WebSite",
      "@id":"#website",
      "url":"https://example.com",
      "name":"Example",
      "potentialAction":{
      "@type":"SearchAction",
      "target":"https:https://example.com/search/key/{search_term_string}",
      "query-input":"required name=search_term_string"
      }
      },

      {
      "@context":"http://schema.org",
      "@type":"Organization",
      "url": "https://example.com",
      "name": "Example",
      "logo":"https://example.com/img/logo.png",
      "@id":"#organization",
      "sameAs": ["https://www.facebook.com/example"]
      }

      ]
      </script>


      As you can see I'm using a friendly URL on the target.



      I have seen people using a query string on the URL like this:



      https://example.com/?search={search_term_string} 


      I did not see people using a friendly URL on the target. It's not allowed?



      And at https://developers.google.com/search/docs/data-types/sitelinks-searchbox it says:




      Verify your search engine implementation by copying the WebSite.potentialAction.target URL from your structured data, replacing search_term_string with a test query, and browsing to that URL in a web browser. For example, if your website is example.com, and you want to test the query "kittens", you would browse to https://www.example.com/search/?q={kittens}.




      I tested this url https://example.com/search/hey/{search_word_here} and I got a 404 not found, but this URL worked: https://example.com/?p=search&tp=key&word={search_word_here}.



      So my question is: Can I use a friendly URL on the target? And the code on my snippet is correct?










      share|improve this question
















      My current URL for searches is this one:



      https://example.com/search/key/seach_word_here


      JSON-LD



      <script type='application/ld+json'>
      [
      {
      "@context":"http://schema.org",
      "@type":"WebSite",
      "@id":"#website",
      "url":"https://example.com",
      "name":"Example",
      "potentialAction":{
      "@type":"SearchAction",
      "target":"https:https://example.com/search/key/{search_term_string}",
      "query-input":"required name=search_term_string"
      }
      },

      {
      "@context":"http://schema.org",
      "@type":"Organization",
      "url": "https://example.com",
      "name": "Example",
      "logo":"https://example.com/img/logo.png",
      "@id":"#organization",
      "sameAs": ["https://www.facebook.com/example"]
      }

      ]
      </script>


      As you can see I'm using a friendly URL on the target.



      I have seen people using a query string on the URL like this:



      https://example.com/?search={search_term_string} 


      I did not see people using a friendly URL on the target. It's not allowed?



      And at https://developers.google.com/search/docs/data-types/sitelinks-searchbox it says:




      Verify your search engine implementation by copying the WebSite.potentialAction.target URL from your structured data, replacing search_term_string with a test query, and browsing to that URL in a web browser. For example, if your website is example.com, and you want to test the query "kittens", you would browse to https://www.example.com/search/?q={kittens}.




      I tested this url https://example.com/search/hey/{search_word_here} and I got a 404 not found, but this URL worked: https://example.com/?p=search&tp=key&word={search_word_here}.



      So my question is: Can I use a friendly URL on the target? And the code on my snippet is correct?







      url schema.org google-sitelink-searchbox






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 18 at 17:23









      unor

      66.1k17139243




      66.1k17139243










      asked Jan 18 at 6:27









      NatalieNatalie

      727




      727
























          2 Answers
          2






          active

          oldest

          votes


















          1














          Of course you have to use the URL that works.



          Google will use the target URL for their Sitelink Searchbox, so that users can search on Google’s SERP and end up on your internal SERP. If you specify a target URL that leads to 404 pages, having this feature makes no sense, and Google would have no interest to enable it for your results.



          If that URL happens to be friendly (e.g., without a query component), so be it.






          share|improve this answer
























          • does the target URL really needs to work with {}? I got the 404 if i put this on the friendly url

            – Natalie
            Jan 18 at 19:08











          • @Natalie: Ah, I see. No, you have to replace the string including the {}. That part from the Google quote is misleading/wrong. So from your example, you should test https://example.com/search/key/kittens in the browser.

            – unor
            Jan 19 at 3:22













          • Got it, so my target and query-input on the snippet is correct? or should i replace search_term_string for something else?

            – Natalie
            Jan 19 at 17:48











          • @Natalie: Apart from the double "https", it seems to be fine (assuming that https://example.com/search/key/kittens works).

            – unor
            Jan 19 at 20:57



















          1














          Agree with above solution from @unor, now answering about you code correction



          Please check the target url in posted JSON-LD:-



           "target":"https:https://example.com/search/key/{search_term_string}",


          Remove the double https:



          Also in case of JSON-LD: you cannot map name value to /{search_term_string}



          A correct way is always like this:-



          <script type="application/ld+json">
          {
          "@context": "http://schema.org",
          "@type": "WebSite",
          "url": "[website url]",
          "potentialAction": {
          "@type": "SearchAction",
          "target": "[website search url]={search_term}",
          "query-input": "required name=search_term"
          }
          }
          </script>


          Microdata:-



          <div itemscope itemtype="http://schema.org/WebSite">
          <meta itemprop="url" content="[website url]"/>
          <form itemprop="potentialAction" itemscope itemtype="http://schema.org/SearchAction">
          <meta itemprop="target" content="[website search url]={search_term}"/>
          <input itemprop="query-input" type="text" name="search_term">
          <input type="submit">
          </form>
          </div>





          share|improve this answer
























          • How should i change this line? "target": "[website search url]={search_term}" i got this error on google structured data testing tool INVALID_SYNTAX.

            – Natalie
            Jan 18 at 19:12











          • @Natalie in that target you have to code for example test like this:- "target": "https://pinterest.com/search?q={test}", "query-input": "required name=test"

            – Deepender
            Jan 19 at 9:51











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54248725%2fcan-i-use-a-friendly-url-on-searchaction%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Of course you have to use the URL that works.



          Google will use the target URL for their Sitelink Searchbox, so that users can search on Google’s SERP and end up on your internal SERP. If you specify a target URL that leads to 404 pages, having this feature makes no sense, and Google would have no interest to enable it for your results.



          If that URL happens to be friendly (e.g., without a query component), so be it.






          share|improve this answer
























          • does the target URL really needs to work with {}? I got the 404 if i put this on the friendly url

            – Natalie
            Jan 18 at 19:08











          • @Natalie: Ah, I see. No, you have to replace the string including the {}. That part from the Google quote is misleading/wrong. So from your example, you should test https://example.com/search/key/kittens in the browser.

            – unor
            Jan 19 at 3:22













          • Got it, so my target and query-input on the snippet is correct? or should i replace search_term_string for something else?

            – Natalie
            Jan 19 at 17:48











          • @Natalie: Apart from the double "https", it seems to be fine (assuming that https://example.com/search/key/kittens works).

            – unor
            Jan 19 at 20:57
















          1














          Of course you have to use the URL that works.



          Google will use the target URL for their Sitelink Searchbox, so that users can search on Google’s SERP and end up on your internal SERP. If you specify a target URL that leads to 404 pages, having this feature makes no sense, and Google would have no interest to enable it for your results.



          If that URL happens to be friendly (e.g., without a query component), so be it.






          share|improve this answer
























          • does the target URL really needs to work with {}? I got the 404 if i put this on the friendly url

            – Natalie
            Jan 18 at 19:08











          • @Natalie: Ah, I see. No, you have to replace the string including the {}. That part from the Google quote is misleading/wrong. So from your example, you should test https://example.com/search/key/kittens in the browser.

            – unor
            Jan 19 at 3:22













          • Got it, so my target and query-input on the snippet is correct? or should i replace search_term_string for something else?

            – Natalie
            Jan 19 at 17:48











          • @Natalie: Apart from the double "https", it seems to be fine (assuming that https://example.com/search/key/kittens works).

            – unor
            Jan 19 at 20:57














          1












          1








          1







          Of course you have to use the URL that works.



          Google will use the target URL for their Sitelink Searchbox, so that users can search on Google’s SERP and end up on your internal SERP. If you specify a target URL that leads to 404 pages, having this feature makes no sense, and Google would have no interest to enable it for your results.



          If that URL happens to be friendly (e.g., without a query component), so be it.






          share|improve this answer













          Of course you have to use the URL that works.



          Google will use the target URL for their Sitelink Searchbox, so that users can search on Google’s SERP and end up on your internal SERP. If you specify a target URL that leads to 404 pages, having this feature makes no sense, and Google would have no interest to enable it for your results.



          If that URL happens to be friendly (e.g., without a query component), so be it.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 18 at 17:37









          unorunor

          66.1k17139243




          66.1k17139243













          • does the target URL really needs to work with {}? I got the 404 if i put this on the friendly url

            – Natalie
            Jan 18 at 19:08











          • @Natalie: Ah, I see. No, you have to replace the string including the {}. That part from the Google quote is misleading/wrong. So from your example, you should test https://example.com/search/key/kittens in the browser.

            – unor
            Jan 19 at 3:22













          • Got it, so my target and query-input on the snippet is correct? or should i replace search_term_string for something else?

            – Natalie
            Jan 19 at 17:48











          • @Natalie: Apart from the double "https", it seems to be fine (assuming that https://example.com/search/key/kittens works).

            – unor
            Jan 19 at 20:57



















          • does the target URL really needs to work with {}? I got the 404 if i put this on the friendly url

            – Natalie
            Jan 18 at 19:08











          • @Natalie: Ah, I see. No, you have to replace the string including the {}. That part from the Google quote is misleading/wrong. So from your example, you should test https://example.com/search/key/kittens in the browser.

            – unor
            Jan 19 at 3:22













          • Got it, so my target and query-input on the snippet is correct? or should i replace search_term_string for something else?

            – Natalie
            Jan 19 at 17:48











          • @Natalie: Apart from the double "https", it seems to be fine (assuming that https://example.com/search/key/kittens works).

            – unor
            Jan 19 at 20:57

















          does the target URL really needs to work with {}? I got the 404 if i put this on the friendly url

          – Natalie
          Jan 18 at 19:08





          does the target URL really needs to work with {}? I got the 404 if i put this on the friendly url

          – Natalie
          Jan 18 at 19:08













          @Natalie: Ah, I see. No, you have to replace the string including the {}. That part from the Google quote is misleading/wrong. So from your example, you should test https://example.com/search/key/kittens in the browser.

          – unor
          Jan 19 at 3:22







          @Natalie: Ah, I see. No, you have to replace the string including the {}. That part from the Google quote is misleading/wrong. So from your example, you should test https://example.com/search/key/kittens in the browser.

          – unor
          Jan 19 at 3:22















          Got it, so my target and query-input on the snippet is correct? or should i replace search_term_string for something else?

          – Natalie
          Jan 19 at 17:48





          Got it, so my target and query-input on the snippet is correct? or should i replace search_term_string for something else?

          – Natalie
          Jan 19 at 17:48













          @Natalie: Apart from the double "https", it seems to be fine (assuming that https://example.com/search/key/kittens works).

          – unor
          Jan 19 at 20:57





          @Natalie: Apart from the double "https", it seems to be fine (assuming that https://example.com/search/key/kittens works).

          – unor
          Jan 19 at 20:57













          1














          Agree with above solution from @unor, now answering about you code correction



          Please check the target url in posted JSON-LD:-



           "target":"https:https://example.com/search/key/{search_term_string}",


          Remove the double https:



          Also in case of JSON-LD: you cannot map name value to /{search_term_string}



          A correct way is always like this:-



          <script type="application/ld+json">
          {
          "@context": "http://schema.org",
          "@type": "WebSite",
          "url": "[website url]",
          "potentialAction": {
          "@type": "SearchAction",
          "target": "[website search url]={search_term}",
          "query-input": "required name=search_term"
          }
          }
          </script>


          Microdata:-



          <div itemscope itemtype="http://schema.org/WebSite">
          <meta itemprop="url" content="[website url]"/>
          <form itemprop="potentialAction" itemscope itemtype="http://schema.org/SearchAction">
          <meta itemprop="target" content="[website search url]={search_term}"/>
          <input itemprop="query-input" type="text" name="search_term">
          <input type="submit">
          </form>
          </div>





          share|improve this answer
























          • How should i change this line? "target": "[website search url]={search_term}" i got this error on google structured data testing tool INVALID_SYNTAX.

            – Natalie
            Jan 18 at 19:12











          • @Natalie in that target you have to code for example test like this:- "target": "https://pinterest.com/search?q={test}", "query-input": "required name=test"

            – Deepender
            Jan 19 at 9:51
















          1














          Agree with above solution from @unor, now answering about you code correction



          Please check the target url in posted JSON-LD:-



           "target":"https:https://example.com/search/key/{search_term_string}",


          Remove the double https:



          Also in case of JSON-LD: you cannot map name value to /{search_term_string}



          A correct way is always like this:-



          <script type="application/ld+json">
          {
          "@context": "http://schema.org",
          "@type": "WebSite",
          "url": "[website url]",
          "potentialAction": {
          "@type": "SearchAction",
          "target": "[website search url]={search_term}",
          "query-input": "required name=search_term"
          }
          }
          </script>


          Microdata:-



          <div itemscope itemtype="http://schema.org/WebSite">
          <meta itemprop="url" content="[website url]"/>
          <form itemprop="potentialAction" itemscope itemtype="http://schema.org/SearchAction">
          <meta itemprop="target" content="[website search url]={search_term}"/>
          <input itemprop="query-input" type="text" name="search_term">
          <input type="submit">
          </form>
          </div>





          share|improve this answer
























          • How should i change this line? "target": "[website search url]={search_term}" i got this error on google structured data testing tool INVALID_SYNTAX.

            – Natalie
            Jan 18 at 19:12











          • @Natalie in that target you have to code for example test like this:- "target": "https://pinterest.com/search?q={test}", "query-input": "required name=test"

            – Deepender
            Jan 19 at 9:51














          1












          1








          1







          Agree with above solution from @unor, now answering about you code correction



          Please check the target url in posted JSON-LD:-



           "target":"https:https://example.com/search/key/{search_term_string}",


          Remove the double https:



          Also in case of JSON-LD: you cannot map name value to /{search_term_string}



          A correct way is always like this:-



          <script type="application/ld+json">
          {
          "@context": "http://schema.org",
          "@type": "WebSite",
          "url": "[website url]",
          "potentialAction": {
          "@type": "SearchAction",
          "target": "[website search url]={search_term}",
          "query-input": "required name=search_term"
          }
          }
          </script>


          Microdata:-



          <div itemscope itemtype="http://schema.org/WebSite">
          <meta itemprop="url" content="[website url]"/>
          <form itemprop="potentialAction" itemscope itemtype="http://schema.org/SearchAction">
          <meta itemprop="target" content="[website search url]={search_term}"/>
          <input itemprop="query-input" type="text" name="search_term">
          <input type="submit">
          </form>
          </div>





          share|improve this answer













          Agree with above solution from @unor, now answering about you code correction



          Please check the target url in posted JSON-LD:-



           "target":"https:https://example.com/search/key/{search_term_string}",


          Remove the double https:



          Also in case of JSON-LD: you cannot map name value to /{search_term_string}



          A correct way is always like this:-



          <script type="application/ld+json">
          {
          "@context": "http://schema.org",
          "@type": "WebSite",
          "url": "[website url]",
          "potentialAction": {
          "@type": "SearchAction",
          "target": "[website search url]={search_term}",
          "query-input": "required name=search_term"
          }
          }
          </script>


          Microdata:-



          <div itemscope itemtype="http://schema.org/WebSite">
          <meta itemprop="url" content="[website url]"/>
          <form itemprop="potentialAction" itemscope itemtype="http://schema.org/SearchAction">
          <meta itemprop="target" content="[website search url]={search_term}"/>
          <input itemprop="query-input" type="text" name="search_term">
          <input type="submit">
          </form>
          </div>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 18 at 18:02









          DeependerDeepender

          215




          215













          • How should i change this line? "target": "[website search url]={search_term}" i got this error on google structured data testing tool INVALID_SYNTAX.

            – Natalie
            Jan 18 at 19:12











          • @Natalie in that target you have to code for example test like this:- "target": "https://pinterest.com/search?q={test}", "query-input": "required name=test"

            – Deepender
            Jan 19 at 9:51



















          • How should i change this line? "target": "[website search url]={search_term}" i got this error on google structured data testing tool INVALID_SYNTAX.

            – Natalie
            Jan 18 at 19:12











          • @Natalie in that target you have to code for example test like this:- "target": "https://pinterest.com/search?q={test}", "query-input": "required name=test"

            – Deepender
            Jan 19 at 9:51

















          How should i change this line? "target": "[website search url]={search_term}" i got this error on google structured data testing tool INVALID_SYNTAX.

          – Natalie
          Jan 18 at 19:12





          How should i change this line? "target": "[website search url]={search_term}" i got this error on google structured data testing tool INVALID_SYNTAX.

          – Natalie
          Jan 18 at 19:12













          @Natalie in that target you have to code for example test like this:- "target": "https://pinterest.com/search?q={test}", "query-input": "required name=test"

          – Deepender
          Jan 19 at 9:51





          @Natalie in that target you have to code for example test like this:- "target": "https://pinterest.com/search?q={test}", "query-input": "required name=test"

          – Deepender
          Jan 19 at 9:51


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54248725%2fcan-i-use-a-friendly-url-on-searchaction%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Homophylophilia

          Updating UILabel text programmatically using a function

          Cloud Functions - OpenCV Videocapture Read method fails for larger files from cloud storage