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:


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:



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




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}}

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}}

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:



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

  • 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


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}}


Link to comment
Share on other sites

  • 5 months later...

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


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.

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...