Jump to content

Theme customization: how to add search queries to KVS sitemap


Tech Support

Recommended Posts

General sitemap structure in KVS

KVS renders sitemap dynamically as a typical web page configured to produce XML format instead of HTML. You can find sitemap page in Website UI -> Pages -> [system] Sitemap:

sitemap_page_structure.thumb.png.8ead45ae7ba389c96e1427309a5d699f.png

Due to specific sitemap structure limitations on the number of links, KVS breaks down sitemap into several sitemap indexes, rendering different entities:

  • Videos
  • Albums
  • Playlists
  • Tags
  • Models
  • Categories
  • Sponsors
  • Channels

Sitemap indexes that can potentially generate more than 50k links are additionally broken down into paginated sitemaps. That's why sitemap page renders 2 blocks for some object types (videos, albums, playlists, models, tags): one block is for listing all pages (e.g. Sitemaps Videos), another block is for listing all objects per page (e.g. Links to Videos).

For categories, sponsors and channels KVS considers that their amount is small, so they are rendered as single lists.

 

Adding search queries into sitemap

Since the number of search queries is potentially unlimited, you should consider adding them as 2 blocks similar to models.

 

1) Open Sitemap page for editing and add the following 2 blocks into it:

{{insert name="getBlock" block_id="search_results" block_name="Sitemaps Search Queries"}}
 
{{elseif $smarty.request.type=='search'}}
   {{insert name="getBlock" block_id="search_results" block_name="Links To Search Queries"}}

Here are the highlighted locations where to add these blocks as their position is quite important:

sitemap_search_blocks.thumb.png.294b10945795abf8cee7290e3e8b85b8.png

 

2) Save page editor. After saving you can see that 2 new blocks were added to page structure with default settings:

sitemaps_search_queries_default.thumb.png.9052f67c15a1e6fce437ca6698ed0c2d.png

links_to_search_queries_default.thumb.png.b1b9d63ab8c1f3bec6ee226f99d0d7e6.png

 

3) Open Sitemaps Search Queries block for editing. Set its template to the following code:

{{section start=1 loop=$nav.page_total+1 name=pages}}
<sitemap>
   <loc>{{$lang.urls.sitemap}}?type=search&amp;from_links_search={{$smarty.section.pages.index}}</loc>
   <lastmod>{{$smarty.now|date_format:"%Y-%m-%d"}}</lastmod>
</sitemap>
{{/section}}

Set Cache lifetime (s) to 86400.

Set the following parameter values:

  • items_per_page = 500
  • var_from = from_sitemaps_search
  • sort_by = Query text Desc

Save this block editor.

 

4) Open Links To Search Queries block for editing. Set its template to the following code:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{{foreach item=item from=$data}}
{{assign var="query" value=$item.query|replace:"-":"[dash]"|replace:"&":"%26"|replace:"?":"%3F"|replace:"/":"%2F"|replace:" ":"-"|replace:"[dash]":"--"|rawurlencode}}
   <url>
       <loc>{{$lang.urls.search_query|replace:"%QUERY%":$query}}</loc>
       <lastmod>{{$smarty.now|date_format:"%Y-%m-%d"}}</lastmod>
       <changefreq>weekly</changefreq>
       <priority>0.6</priority>
   </url>
{{/foreach}}
</urlset>

Set Cache lifetime (s) to 86400.

Set the following parameter values:

  • items_per_page = 500
  • var_from = from_links_search
  • sort_by = Query text Desc

Save this block editor.

 

5) Now you should have a fully working search sitemap inside your main sitemap index. Try opening your sitemap and look for "search" keyword:

http://domain.com/sitemap.php

 

If your database has search queries, you should see something like this in your sitemap:

http://domain.com/sitemap/?type=search&from_links_search=1
http://domain.com/sitemap/?type=search&from_links_search=2
....
 
  • Like 5
  • Thanks 2
Link to comment
Share on other sites

  • 2 years later...
  • 3 months later...

I see its block has default code like this

image.png.31e4289f23ee625515e0979e3ad4f1af.png

Do I need to replace with whole below code to the template or put it inside <div> ?

On 1/8/2020 at 1:43 PM, Tech Support said:
{{section start=1 loop=$nav.page_total+1 name=pages}}
<sitemap>
   <loc>{{$lang.urls.sitemap}}?type=search&amp;from_links_search={{$smarty.section.pages.index}}</loc>
   <lastmod>{{$smarty.now|date_format:"%Y-%m-%d"}}</lastmod>
</sitemap>
{{/section}}

 

Link to comment
Share on other sites

  • 5 months later...

i have a lot of these links (as you can see in the screenshot)

https://domain.com/search/%EF%BD%91%EF%BD%89%EF%BD%81%EF%BD%8F%EF%BD%8E%EF%BD%89%EF%BD%95%EF%BC%B4%EF%BC%B4/

is this normal ? 

is this affect my website ? 

Any one can help ?

Capture d'écran 2024-01-31 124739.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...