0

I would like knowing if anyone has implemented Search Result page with other filters in SXA supporting "Querystring" (serverside) instead of "Hash" (AJAX) to achieve SEO. OOTB SXA search component returns the response through AJAX, what if google crawls your search or listing page.

4
  • 2
    We were thinking about moving from hash parameters to query string in the past. But this would basically mean to rewrite whole search logic and we give up. We are using backbone.js (that is pretty old logic, it was written in times when beckbone.js was quite popular) in most of the search scripts. Backbone by default is using a hash to store params. There are some articles showing that it is possible to switch to query string but just at the beginning we already found a couple of issues with this. Aug 8 '19 at 8:57
  • Because SEO companies keep asking this request and we are in same situation that it will require complete rewrite of the logic. Aug 8 '19 at 9:19
  • I've implemented a SEO friendly version of a SXA listing page using the search components. What I actually did was creating a custom component that uses the scope defined in SXA to do the search, as well as the pagination from SXA. The output is done with variants so we are reusing lots of SXA stuff. It's a bit much to show all code here. The pagination part can be found on ggullentops.blogspot.com/2018/12/…. The reuse of the scope will be done in the near future..
    – Gatogordo
    Aug 8 '19 at 9:24
  • Believe me - you don't want to do that... Aug 8 '19 at 10:45
2

I've implemented a SEO friendly version of a SXA listing page using the search components. What I actually did was creating a custom component that uses the scope defined in SXA to do the search, as well as the pagination from SXA. The output is done with variants so we are reusing lots of SXA stuff.

It's a bit much to show all code here, but lets try to give you the highlights. The pagination part can be found on https://ggullentops.blogspot.com/2018/12/sxa-pagination-on-custom-component.html. The reuse of the scope will be done in the near future..

Pagination

For pagination on a custom component:

  • Your rendering does need rendering parameters. The rendering parameters temlate for your component should inherit IPaginable and IPagination (both from the Feature/Experience Accelerator/Page Content/Rendering Parameters folder
  • The rendering item needs IsPaginationEnabledRendering true as (other) property
  • Your controller needs to derive from PaginableController.
  • Implement the function PaginationConfiguration in the controller to generate a IListPagination. This is the object you can pass to the repository that fetches the data to select the required page.
  • Implement the function OnActionExecuting in the controller to initialize the pagination context ListPaginationContext

Scope

To reuse the scope, note that a scope is actually a rendering parameter. You can read it - will be a string with the guid in it. To get a query based on the scope:

var scopeItem = Sitecore.Context.Database.GetItem(new ID(scope));
var scopeQuery = scopeItem[Constants.ScopeQuery];
var model = SearchStringModel.ParseDatasourceString(scopeQuery);

using (var context = searchContextBuilder.GetSearchContext(indexName))
{
  var query = LinqHelper.CreateQuery<ContentPage>(context, model);
1
  • Converted to a comment as this falls under a link only answer.
    – Richard Seal
    Aug 8 '19 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.