• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.4 SearchAction markup for Google?

dethfire

Well-known member
#1
I got an email from Google saying "Make your site ready for the new sitelinks search box".

They say I need to:
Add the necessary markup to your site's homepage
We recommend using schema.org/SearchAction markup with JSON-LD, but you can also use microdata.

Does Xenforo support this?
 

Brent W

Well-known member
#4
Make your site ready for the new sitelinks search box
September 15, 2014


To: Webmaster of http://www.aspiescentral.com/,

Google systems have detected that your site may be eligible for the new sitelinks search box. With it, you can make it easier for your visitors to reach specific content on your site directly from Google Search. We want to help you set up your site to take advantage of the new search box.

Here’s how to make sure your site is ready:
1Verify you’ve got a functioning site-specific search engine
If you’ve got a Google Custom Search Engine, that works too.
2Add the necessary markup to your site's homepage
We recommend using schema.org/SearchAction markup with JSON-LD, but you can also use microdata.
3Set up a preferred canonical URL for your homepage
Make sure all other page versions point to the one you want (use the rel="canonical" link element)
Need more help?
•Learn more about Sitelinks Search box on our blog.
•See setup and code samples on our Sitelinks Searchbox guide.
Ask more questions on the forum - mention message type [WNC-389902]

Is this something that is already built into XenForo, specifically the number 2 option?
 

zagorskey

Active member
#7
I'm also curious. Xenforo's search method returns a link in this form:

Code:
http://website.com/search/118457/?q={what_you_searched_for}&o=date
so apparently every search being made has its own ID. How can we get the variable generating that one?
 

FredC

Well-known member
#12
Is this already something XF does with Microdata? Do we need to do any of the install steps listed in this thread?

Code:
<div itemscope itemtype="http://schema.org/WebSite">
  <meta itemprop="url" content="https://www.example-petstore.com/"/>
  <form itemprop="potentialAction" itemscope itemtype="http://schema.org/SearchAction">
    <meta itemprop="target" content="https://query.example-petstore.com/search?q={search_term_string}"/>
    <input itemprop="query-input" type="text" name="search_term_string" required/>
    <input type="submit"/>
  </form>
</div>
and if not where would the above example go?
 

Sunka

Well-known member
#15
@Mike yes, but where exactly to put this code.
My forum is www.pijanitvor.com.
What exactly to put in this row: <metaitemprop="target"content="http://query.pijanitvor.com/search?q={search_term_string}"/>
Couse search on my forum have this part in link /search/168626/?q=orada&o=date
So apparently every search being made has its own ID. How can we get the variable generating that one?

Is that code below correct? If yes, I have to put that code anywhere in home page. What template?

Code:
<div itemscope itemtype="http://schema.org/WebSite">
  <meta itemprop="url" content="http://www.pijanitvor.com/"/>
  <form itemprop="potentialAction" itemscope itemtype="http://schema.org/SearchAction">
    <meta itemprop="target" content="http://query.pijanitvor.com/search/?q={search_term_string}"/>
    <input itemprop="query-input" type="text" name="search_term_string" required/>
    <input type="submit"/>
  </form>
</div>
 

RoldanLT

Well-known member
#16
For now, if any want's to implement it.
Add this code on PAGE_CONTAINER template below footer area.
Code:
<xen:if is="{$contentTemplate} == 'forum_list'">
<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "WebSite",
  "url": "https://www.phcorner.net/",
  "potentialAction": {
    "@type": "SearchAction",
    "target": "https://www.phcorner.net/search/search?keywords={search_keywords}",
    "query-input": "required name=search_keywords"
  }
}
</script>
</xen:if>
Just replace with your own domain.
I implement it already almost a week now.
 

Sunka

Well-known member
#17
Add this code on PAGE_CONTAINER template below footer area.
You mean like this:
Code:
<footer>
    <xen:include template="footer" />
</footer>

<xen:if is="{$contentTemplate} == 'forum_list'">
<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "WebSite",
  "url": "http://www.pijanitvor.com/",
  "potentialAction": {
    "@type": "SearchAction",
    "target": "http://www.pijanitvor.com/search/search?keywords={search_keywords}",
    "query-input": "required name=search_keywords"
  }
}
</script>
</xen:if>

<xen:include template="page_container_js_body" />

</xen:hook>
</body>
</html>
 

RoldanLT

Well-known member
#18
I did it like this:
HTML:
<footer>
    <xen:include template="footer" />
</footer>

<xen:include template="page_container_js_body" />
<xen:if is="{$contentTemplate} == 'forum_list'">
<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "WebSite",
  "url": "https://www.phcorner.net/",
  "potentialAction": {
    "@type": "SearchAction",
    "target": "https://www.phcorner.net/search/search?keywords={search_keywords}",
    "query-input": "required name=search_keywords"
  }
}
</script>
</xen:if>
</xen:hook>
</body>
</html>