Tuesday, November 24, 2026

Blocking PDFs from Google in Sitecore

Blocking Specific PDFs from Google in Sitecore: Why robots.txt is not the good idea and X-Robots-Tag is


Recently I had to a task to hide specific PDFs from Google Search. The PDF's are publicly accessible but they just don't want the content indexed. 

At first glance, that sounds like a simple task with a disallow rule in the robots.txt file. But first glances can be wrong.
Using robots.txt to remove or hide PDFs from Google is a common misconception in web development— in fact, it can even make it worse.

Why robots.txt Is the Wrong Tool (and X-Robots-Tag Is the Right One)

Crawling and indexing are different things. Google’s official specifications point us in the right direction and make sure we use the right tools to stop indexing.

robots.txt only controls crawling, not indexing.

Per Google’s Introduction to robots.txt, a Disallow rule only tells compliant crawlers not to fetch the URL. But, if internal pages or external sites link to that PDF, Google can still index the URL itself and display it in search results. It is even mentioned in bold that robots.txt is not a mechanism for keeping a web page out of Google.

PDFs can’t hold <meta> tags.

On a HTML page, you can add a tag <meta name="robots" content="noindex" /> into the <head> section.  A PDF document however does not have a html head so it cannot use this tag. It is recommended to use the X-Robots-Tag HTTP response header for non-HTML resources like PDFs, videos, and images in its Robots meta tag, data-nosnippet, and X-Robots-Tag specifications.

The real trap: combining robots.txt with noindex.

As Google warns in Block Search indexing with noindex, a noindex rule only works if Googlebot is allowed to crawl the URL. If you block a PDF in robots.txt, that access is actually denied and Googlebot will not request the file, and will not see your noindex header, so it will leave an already-indexed PDF sitting in search results. You could rely on the path it used to find it in the first place, but I wouldn't count on that.

I need to emphasize as a security side note that the X-Robots-Tag is a directive for search engines, not an access-control mechanism. The document is still available to everyone. 

So now we know: we do not block the access in the robots.txt file and we do want to add a header in the response.

This was implemented on a Sitecore (10.2) site with SXA and MVC. I'll cover that solution and explain later how this can be ported to a more modern setup with SitecoreAI.


The Sitecore 10.2 (.NET / SXA) Implementation

We want content authors to toggle search engine visibility per PDF (inside the Media Library) so we cannot use hardcoded rewrite rules or any other path-based solution. So we extend the pdf templates.

Step 1: templates

  1. Create a new base template - e.g.  _RobotsAwareMedia.
  2. Add a section (e.g., Indexing or SEO) with a Checkbox field named NoIndex.
    I would suggest to make the field Shared as blocking a PDF probably should apply across all languages and versions
  3. Add _RobotsAwareMedia to the template inheritance of both built-in Sitecore PDF media templates:
    • /sitecore/templates/System/Media/Unversioned/Pdf
    • /sitecore/templates/System/Media/Versioned/Pdf
    These are probably not yet in your serialization if you are using that - you might want to add them.


Step 2: a custom MediaRequestHandler

We can override Sitecore’s media request handler so that whenever a PDF is requested, it checks the NoIndex field and appends X-Robots-Tag: noindex, nofollow to the HTTP response.

Because this solution uses SXA, our handler inherits from  the SXA one. If you are on a non-SXA Sitecore solution, simply inherit from the default one. You can find the one you are currently using the web.config as you will see when we get to the configuration.

>using System;
using System.Web;
using Sitecore;
using Sitecore.Data.Items;
using Sitecore.Resources.Media;

namespace XX.Foundation.RequestHandlers
{
    public class RobotsAwareMediaRequestHandler : Sitecore.XA.Foundation.MediaRequestHandler.MediaRequestHandler //Sitecore.Resources.Media.MediaRequestHandler 
    {
        protected override bool DoProcessRequest(HttpContext context, MediaRequest request, Media media)
        {
            Item item = media?.MediaData?.MediaItem;
            if (item != null && string.Equals(media.MediaData.Extension, "pdf", StringComparison.OrdinalIgnoreCase) &&
                    MainUtil.GetBool(item["NoIndex"], false))
            {
                context.Response.AppendHeader("X-Robots-Tag", "noindex, nofollow");
            }

            return base.DoProcessRequest(context, request, media);
        }
    }
}

A few notes on the code. Appending the header before calling the base function is intentional as the base implementation sets cache/status headers and setting our header first guarantees it is attached before headers are sent. We check for the pdf extension, limiting the field lookup to PDFs, avoiding unnecessary overhead on other media items like images. 
Also note that we set both noindex and nofollow. Noindex keeps the PDF out of Google’s search index, while nofollow instructs crawlers not to follow links embedded inside the document.


Step 3: registering the handler (in Web.config)

Sitecore’s media handler is an IIS HTTP handler mapped to sitecore_media.ashx in Web.config under <system.webServer><handlers>, which means it cannot be patched via App_Config/Include files.

Replace the default SXA handler registration in Web.config with your custom handler:

<!--<add verb="*" path="sitecore_media.ashx" type="Sitecore.XA.Foundation.MediaRequestHandler.MediaRequestHandler, Sitecore.XA.Foundation.MediaRequestHandler" name="Sitecore.MediaRequestHandler" />-->
<add verb="*" path="sitecore_media.ashx" type="XX.Foundation.RequestHandlers.RobotsAwareMediaRequestHandler, XX.Foundation" name="Sitecore.MediaRequestHandler" />

Don't forget to check how your web.config changes make it to the live production site - might be xdt transformations...


How This Translates to Headless (SitecoreAI) with Next.js

If you are moving toward SitecoreAI (or already on it) with a Next.js frontend and Experience Edge, you no longer have a .NET Content Delivery server, IIS Web.config, or MediaRequestHandler to override.

Still, the core principle stays identical—only the enforcement layer moves from .NET to the Edge / Next.js delivery part.

First, there is an interesting SitecoreAI detail:

  • By default, Experience Edge blocks indexing on all media. When media is served from the default edge domain, it automatically gets a X-Robots-Tag: noindex.
  • Custom hostnames revert this, so when you configure a custom hostname which you probably do, Google can index your documents again as Experience Edge omits that global X-Robots-Tag: noindex header.

Once you use a custom media domain, you’re right back to the per-PDF control. We can use the same architecture, just in different technologies. We keep the exact same template design. The handler code that used to be in C# now is created in the Next.js implementation. Route the pdf request through the rendering host and add the exact same header there.


Things to verify in production environments

In real-world scenarios your Sitecore site and its http headers probably pass through multiple layers between your application and the Google bot. So you will need to check:

CDN Caching and Header Stripping

If a PDF was already public and cached by your CDN, toggling NoIndex and publishing in Sitecore won’t update the cached response at the CDN edge until the TTL expires or the URL is purged.
Also, verify that your CDN is configured to pass through origin X-Robots-Tag header instead of stripping or overwriting them.


WAF / Firewall Rules

Assuming your WAF is not blocking Google bot, check that it is also not stripping your newly created header. Make sure to test through all the layers and not directly to the Content Delivery server.

robots.txt and IIS <customHeaders>

Esnure your robots.txt has no Disallow rule for your pdfs. Also verify that the Web.config <customHeaders> and/or IIS URL Rewrite outbound rules do not interfere with your X-Robots-Tag values.

GET vs. HEAD Requests and 304 Not Modified

Sitecore’s sitecore_media.ashx handler uses verb="*", so both GET and HEAD hit DoProcessRequest. Always test with both because some intermediate layers might treat headers on HEAD and GET differently.
Sitecore caches media on disk and handles this inside base.DoProcessRequest, so keeping our append before the base ensures the header isn’t skipped on 304 Not Modified requests.

How to Verify It Works

Use any tool you want to fetch a pdf from your site and verify the headers in the response. They should contain the robots tag.


Conclusion

Blocking PDFs from Google isn’t a robots.txt problem - it’s an HTTP response header problem. And one that can rather easily be done in Sitecore.


Thursday, November 19, 2026

Scriban in a classic Sitecore

A Sitecore Dictionary, extended with Scriban

If you have worked with Sitecore (SXA) you will know the Sitecore Dictionary.  There is a version in Sitecore, although I'm not sure if many people use it but in SXA, you probably appreciate the per-site dictionary implementation. This post is based on a non-SXA implementation using a custom-built dictionary offering very similar functionality to the SXA dictionary. The idea here will work in a SXA environment as well though. And actually, it might also work in a headless environment with JSS or SitecoreAI although it depends on your setup as Scriban does not have a javascript package but there are alternatives like Liquid.

So we do not have SXA's rendering variants available in this project, but we ran into an interesting requirement where a templating engine like Scriban turned out to be the missing piece—not in a rendering variant this time, but on top of the dictionary itself. 

Scriban

I already wrote quite some posts on scriban - /search/label/scriban. In sitecore-sxa-93-scriban I explained for instance how to use the dictionary inside Scriban. 

Scriban is a lightweight, fast, and sandboxed text templating engine for .NET, we can pass any data model into a dictionary and let Scriban render the final text.  This was ideal for our issue.


Plain dictionary texts and simple string replacements

Usually, dictionary entries are simple static strings: a button label or a validation message and so on. Sometimes when you need dynamic values in there, you add a placeholder like `{0}` and use string.Format - or maybe a named token like `{{discount}}` and a .Replace(...).

That works fine for simple cases, until your text starts depending on business data. Think about texts that explain a pricing structure, promotional rules, or shipping conditions. In many cases even those are rather general but now our customer really needed to get a changing amount of specific numbers in there - and yes, they still wanted to edit the texts. 

Simple string replacement quickly hits a wall here. Positional placeholders are fragile. One is fine, two maybe, but when you have too many editors and translators might make mistakes - causing bugs. There is also no conditional logic like if / else.  What if a sentence should only appear when a discount applies? And also, there are no loops. We do have a variable number of prices or promotions to show, so a loop is needed.
Creating multiple entries for each conditional statement, or building a list in code by concatenating dictionary fragments is not something you really want to do.


The idea: Scriban as a templating engine on top of the dictionary

Instead of keeping all that formatting and conditional logic in C#, we decided to treat the dictionary entry as a Scriban template and enrich it with structured data from code at render time.

One important caveat: this is obviously not meant for every dictionary key, nor for every regular editor. Writing templates with loops and conditions requires a bit of technical understanding. And of course, the templates are written by the developers (us) - but even to change/translate the texts inside it is best that the editors understand what is going on. 

If a dictionary entry contains no Scriban tags at all, Scriban simply outputs the plain text as-is. This means we could put it on top of all entries, but we still decided not to. 

The implementation

At the core of this solution is a small service that takes the raw text (fetched from the dictionary - although this could come from anywhere) and an IDictionary containing the data we want to expose:

using System.Collections.Generic;
using Scriban;
using Scriban.Runtime;

public interface IScribanDictionaryRenderer
{
    string Render(string templateSource, IDictionary<string, object> templateData);
}

public class ScribanDictionaryRenderer : IScribanDictionaryRenderer
{
    public string Render(string templateSource, IDictionary<string, object> templateData)
    {
        if (string.IsNullOrWhiteSpace(templateSource))
        {
            return string.Empty;
        }

        var parsedTemplate = Template.Parse(templateSource);
        if (parsedTemplate.HasErrors)
        {
            // Log parsedTemplate.Messages here
            return templateSource;
        }

        var scriptObject = new ScriptObject();
        if (templateData != null)
        {
            foreach (var entry in templateData)
            {
                scriptObject[entry.Key] = entry.Value;
            }
        }

        var context = new TemplateContext();
        context.PushGlobal(scriptObject);

        return parsedTemplate.Render(context);
    }
}


A few things to note in this code, as this is mvp material to test the idea and not ready to just copy into production. Think of it is something your AI buddy gave you - or do you just push that to live environments? ☺

There has to be a graceful handling of syntax errors. If an editor makes a typo in the Scriban template  the parsedTemplate.HasErrors will be true. This needs to be logged and handled without crashing. We are here simple returning the original template. This is handy for development, but that is probably not something you want to in production.

Every key-value pair in templateData is and pushed onto the Scriban TemplateContext. Note that if you nwat to push this even further you could also customize Scriban here by registering custom functions . I did write some posts on how to do that in a SXA context: custom SXA Scriban extensions and exposing custom objects in Scriban. 

You should be careful with Scriban's default naming convention. By default, Scriban converts PascalCase property names on your C# objects to snake_case (so a property `MinQuantity` on a C# class becomes `min_quantity` inside the template). If this is an issue, you can look at member renamers.

By default the culture will be CultureInfo.InvariantCulture. If your templates use Scriban's formatting helpers like `math.format` (probably not, but you never know) you should check the culture settings with context.PushCulture(Sitecore.Context.Language.CultureInfo) so numbers and dates match the current site language.


Example

Let's look at a real-world example. Suppose we have a product or promotion with a base price, an optional free-shipping threshold, and a dynamic list of volume discounts.

In C#, we prepare the data, fetch the template from the dictionary service and pass it to our Scriban renderer. Assuming you can write this code, let's focus on how the template could look:

<p>
  The standard price is {{ currency }}{{ base_price }} per unit.
  {{ if free_shipping_threshold > 0 }}
    Orders above {{ currency }}{{ free_shipping_threshold }} qualify for free shipping.
  {{ end }}
</p>

<p>Volume discounts:</p>
<ul>
  {{ for tier in tiers }}
    <li>Buy {{ tier.min_quantity }} or more: {{ currency }}{{ tier.unit_price }}/unit</li>
  {{ end }}
</ul>

Notice how much flexibility the editor gets here without requiring a single code deployment. But also, how we managed to limit the number of dictionary texts and custom coding replacing texts.


Conclusion

Putting Scriban on top of a Sitecore dictionary is a small piece of code -literally one lightweight class-that unlocks a lot of power when static text or simple token replacement just isn't enough.

Of course, just like with Scriban in SXA rendering variants, the key is balance: keep simple labels simple, make sure the people editing these dictionary templates understand the templates, be ready for syntax errors and reserve this approach for cases where dynamic data, conditions, and loops genuinely save you from hardcoding text-building logic in C#.


Wednesday, November 18, 2026

xConnect-Only in the SearchStax Cloud Connector for Sitecore

 xConnect-Only Deployments in the SearchStax Managed Search Connector for Sitecore

People who read my blog posts know I still have a few projects on good old Sitecore XP. This is a post that has been hanging around for a while. Earlier this year I was involved in an upgrade process where we also moved the indexes from Azure Search to Solr.  As you probably know Sitecore stopped support for Azure Search completely in 10.2. Although you can host your own Solr instance, there are other options with companies that take away some of the burden and manage that Solr for you. SearchStax is one of them and quite familiar in the Sitecore community. So while setting up the latest Sitecore version for the upgrade (10.4 at that time) we also switched to SearchStax Managed Search.  

We bumped into a small issue - and have a fix for it so it's worth sharing. Although I must admit the issue was also caused by something we did wrong - but we're human, so that happens :) 


If you are using SearchStax Managed Search (Solr-as-a-Service) with Sitecore XP, the SearchStax Cloud Connector for Sitecore is a huge time-saver. Instead of manually uploading ZooKeeper configs, creating collections, and configuring aliases, the PowerShell script (sitecore-searchstax-connector.ps1) automates the heavy lifting based on a config.yml file. The documentation on this config file is pretty good and it has lots of options to set everything exactly as you need - including custom indexes.

Due to my own mistake, I ran into a scenario where I needed to configure only xConnect indexes —without touching the standard Sitecore XP platform indexes again. Of course, I could remove everything and start all over but according to the SearchStax documentation, this should work out of the box. In practice, however, running the script in XCONNECT-only mode hit a subtle bug.


The configuration modes

In config.yml, the configurationMode setting supports three values:

  • XP – Sets up the Sitecore platform and marketing indexes only.
  • XCONNECT – Sets up the xDB search indexes (xdb / xdb_rebuild) only.
  • XP|XCONNECT – Sets up both at the same time.

When the script initializes, it check the configurationMode and sets boolean flags to determine later on what to do. 

The issue

When I set configurationMode: "XCONNECT", the script failed. Apparently it was unable to resolve the Solr version which of course broke the code in a later phase.

Right after initialization, the script maps sitecoreVersion to the corresponding $solrVersion (for example, 10.0.* → 8.4.0, 10.4.* → 8.11.2).  The catch was that this version-mapping logic only lived inside the XP branch and was not executed when this flag was not true.

Which is the case when configurationMode is set strictly to "XCONNECT". As a result, the script skipped the version check and left $solrVersion empty.  Even though the script later entered the the code to perform all tasks needed for the xDB indexes, passing an empty $solrVersion broke the execution there.

The Fix

To support XCONNECT-only execution properly, I added an extra block in sitecore-searchstax-connector.ps1 to resolve the solr version in this case:

elseif($global:isConfigureXConnect -eq "true") {
    if ($sitecoreVersion -eq "9.0.2") {
        $solrVersion = "6"
        $global:isUniqueConfigs= $true
    } elseif ($sitecoreVersion -eq "9.1.1") {
        $solrVersion = "7.2.1"
    } elseif ($sitecoreVersion -eq "9.2.0") {
        $solrVersion = "7.5.0"
    } elseif ($sitecoreVersion -eq "9.3.0") {
        $solrVersion = "8.1.1"
    } elseif ($sitecoreVersion -like "10.0.*") {
        $solrVersion = "8.4.0"
    } elseif ($sitecoreVersion -like "10.1.*") {
        $solrVersion = "8.4.0"
    } elseif ($sitecoreVersion -like "10.2.*") {
        $solrVersion = "8.8.2"
    } elseif ($sitecoreVersion -like "10.3.*") {
        $solrVersion = "8.11.2"
    } elseif ($sitecoreVersion -like "10.4.*") {
        $solrVersion = "8.11.2"
    }
   ....
}


With $solrVersion populated, running the connector with configurationMode: "XCONNECT" now executes properly, uploading only the xConnect ZooKeeper configuration, creating the xdb collections, wiring up the aliases, and updating the xConnect schema.


When to use...

Being able to run XCONNECT independently is probably not something you regularly do but it can be helpful helpful when you really want to distribute everything - or if you screwed up and you want to redo just the xdb indexes :) 


Links

If you need this before it's merged, you can use my updated version or review the the pull request:


Also do check the SearchStax Documentation because as you know we already have 10.5 now so my version is outdated. But I do assume the issue is still in there. 

Good luck with your SearchStax solr's - except for this minor issue it worked like a charm for us.








Friday, October 30, 2026

Sitecore XP certificate update

Changing the xDB Certificate on Sitecore 10 XP (Azure PaaS)

Rotating certificates in a distributed enterprise CMS environment like Sitecore XP on Azure PaaS takes quite some steps. Maybe this can be automized, maybe not...  I just know we never did as this only happens very often. But when it does, whether you are dealing with an upcoming certificate expiration  date or a mandatory security rotation, missing even a single configuration file or setting will cause xDB communication to fail.

In a Sitecore xDB setup, services talk to each other securely over https using certificate thumbprints. If you miss a role, update the wrong configuration file, or forget to update  the website_load_certificates environment variable, the App Service won't be able to access the certificate. Communication will fail and errors will occur.

Certificate errors

Roles like Content Management (CM) or Content Delivery (CD) will fail to communicate securely with xDB Collection, Reference Data, or Marketing Automation services. Your visitors might not notice as the website will probably be still running, but visitors' interaction data will fail to be recorded or processed, leading to faulty analytics dashboards and broken visitor profiles.

However, if you check your logs (Application Insights and/or Sitecore log files) you will quickly notice a flood of messages like: 

  • "X509Certificate" exceptions
  • "The certificate with thumbprint [...] could not be found"
  • "A call was made on a closed Stream"...
  • ...
I can assure you you don't want this. But almost every "Sitecore developer" has bumped into a certificate error at least once. The problem is that the error not always tells you exactly what and where is wrong - you just know it's a certificate issue.

Checklist

To make life easier for my team and anyone else tackling this task, I’ve put together this checklist for updating the xDB communication certificate on a Sitecore 10 XP Azure PaaS setup. Note that this is a checklist for one of our setups. Other setups might (probably will) need  some adjusting - not in the locations as such but mainly on the environments as you can have more servers, slots and so on. The main idea however will stay the same: make sure not to forget any location on any environment. 

Prerequisites / Global Setup

First of all, you'll need to install the new certificate into your Azure App Service Certificate store and/or Key Vault.

At the end (once everything is switched, restarted and verified) remove the old certificate. This might seem unnecessary but it isn't.  Just make sure everything is tested before you do so.


Role-by-Role Update Checklist

Connectionstrings

When we talk about updating connectionstring note that this can be on several locations. Well, each app will have them one one location but it can be different for each solution and even within a solution it can be different for the various apps. The options are:
  • in Azure in the KeyVault - referenced in the App environment variables : in this case you need to update the value in the vault and make sure the app is restarted
  • in Azure in the App service environment variables connection strings section : use the bulk edit - in this case the edits will trigger a restart
  • a connectionstrings.config file in the app_config : this is the default in the Sitecore setup but normally on apps where you desploy your own code this should not be used

1. Content Management (CM)

  • Update the certificate thumbprint in your connection strings. This might trigger an App Service restart - depending on the location.
  • Update the `WEBSITE_LOAD_CERTIFICATES` app environment variable with the new thumbprint.
    Without this, the App Service won't mount the certificate into the local machine store, resulting in "certificate not found" errors so it's rather crucial.
  • If the certificate is also used for SSL, bind the certificate to the CM App Service
  • Restart.

2. Content Delivery (CD)

  • Update the certificate thumbprint in the connection strings.
  • Update the thumbprint on `WEBSITE_LOAD_CERTIFICATES`. 
  • Assign the SSL certificate for each custom domain that uses this certificate bound to the CD instances (restarts).
  • In case you have one or more deployment slots: don't forget to repeat all the steps above for your each slot. Not all might be needed, but check to be sure.
  • Restart (all needed slots)

3. Experience Analytics / Collection (XC-collect)

  • Update validateCertificateThumbprint in AppSettings.config in the App_Config folder
  • Restart

4. Experience Analytics / Reference Data (XC-RefData)

  • Update validateCertificateThumbprint in AppSettings.config.
  • Restart

5. Marketing Automation Operations (MA-Ops)

  • Update validateCertificateThumbprint in AppSettings.config.
  • Update the certificates in ConnectionStrings.config.
  • Update the thumbprint on WEBSITE_LOAD_CERTIFICATES in the environment variables.
  • Update the certificates in the connectionstrings.config of the automation job in App_Data\jobs\continuous\AutomationEngine\App_Config
  • Restart

6. Marketing Automation Reporting (MA-Rep)

  • Update validateCertificateThumbprint in AppSettings.config.
  • Update the thumbprint on WEBSITE_LOAD_CERTIFICATES.
  • Restart

7. Processing (PRC)

  • Update the thumbprint on WEBSITE_LOAD_CERTIFICATES.
  • Update the thumbprint in the connection strings.
  • Restart

8. Experience Analytics Search (XC-Search)

  • Update validateCertificateThumbprint in AppSettings.config.
  • Restart

9. Sitecore Identity Server (IS)

  • Update the thumbprint in wwwroot\Config\production\Sitecore.IdentityServer.Host.xml.
  • Update the thumbprint on WEBSITE_LOAD_CERTIFICATES. 
  • Restart

10. Cortex Reporting (Cortex-Rep)

  • Update the thumbprint on  WEBSITE_LOAD_CERTIFICATES.
  • Update validateCertificateThumbprint in AppSettings.config
  • Update the certificates in the connectionstrings.config for the processing job in App_Data\jobs\continuous\ProcessingEngine\App_Config.
  • Restart


Infrastructure / Code Base Updates (ARM / Bicep / Terraform)

Whatever you are using for deployment, your templates or variable files might include the thumbprint. To make sure your next automated deployment does not overwrite your fixes, update your infrastructure-as-code files.

  • Update the thumbprints in your setup templates (`environmentsettings.json`).
  • Replace the physical certificate file/reference in your repository if stored or referenced directly.


Post-Update Verification Checklist

Once all roles have been updated and restarted, check the logs (Application Insights probably) and make sure you do not have any certificate exceptions.

You can also verify the Experience Analytics dashboard in Sitecore to ensure graphs are populating correctly.

Keep an eye on the logs for the next 24h just to be sure...


And then convince your customer to move to SitecoreAI so you do not have to do this again. I know tis is easier said than done - the fact that I am writing blogs on Sitecore XP is the best proof :)


Monday, October 12, 2026

Sitecore SXA resolvedlinks

Sitecore SXA ComputedIndexField: resolvedlinks


A while ago - actually 8 years apparently, time flies... - I wrote an article about Sitecore SXA and the search related features. It included the use of "resolvedlinks".  This is a piece of code that is used by SXA for some ComputedFields in the index, but it can be used for our own use as well. 

A Sitecore "computed index field" lets you inject custom logic to generate and/or transform index data dynamically during the indexing process instead of mapping raw field text directly. This allows you to add a field that is not a direct copy of the content of a field. For the rest it is a normal index field, with all the options for such a field on tokenization and such. 

The idea behind the resolvedLinks implementation is simple. If you have an item that contains a reference field like a Multilist of Treelist , the index will store the guids used in that reference field as that is the raw content. In some cases you do want not the guid but an actual value representing that reference. 

In that old blog I had an example as we used the resolvedLinks to add computed index fields to be used as facets. You do not want to show guids as facets - you want an actual string that defines the referenced item.

I already used it on other places as well when I wanted the data to be available in the index for retrieval to avoid having to fetch the referenced items on each request. Several use cases are possible, but recently we bumped into an issue where it didn't fully match our requirements anymore. 

The issue was quotes. Or other weird characters probably. But definetely quotes. 

Taxonomy information architecture

Actually it comes to down to how we setup things in the first place. We never assumed the editors would be using those characters in page titles and that was our mistake. So the "resolvedLinks" is linked to the title of those pages (as requested by the customer and the analysts as this was the most consistent solution). And that is a bad idea...  so we learned now that we should provide an additional field to enter the name or title to use in the taxonomy. 

But of course, editors are human (for now) and as such lazy.  I know there are options to make sure this field is filled, using a copy of the title if needed and such.  But we also have other options. 

The solution

First of all, we did create the extra field on the items to add an optional taxonomy title. Optional, because if the page title was sufficient that is also ok for us. And this also means all the existing data is also still good - backwards compatibility is important on existing sites with quite a bit of content.

We decided to create our own version of the resolvedLinks, one that supports a fallback field. This way we can attach it to the new taxonomy title field but keep the title field as backup in case the new field is empty.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using Sitecore.ContentSearch;
using Sitecore.ContentSearch.ComputedFields;
using Sitecore.Data;
using Sitecore.Data.Items;
using Sitecore.Globalization;

namespace Foundation.Taxonomy.Index
{
    public class ResolvedLinksWithFallback : AbstractComputedIndexField
    {
        public ResolvedLinksWithFallback()
        {
        }

        public ResolvedLinksWithFallback(XmlNode node) : base(node)
        {
            ContentField = node.Attributes?["contentField"]?.Value;
            FallbackContentField = node.Attributes?["fallbackContentField"]?.Value;
            ReferenceField = node.Attributes?["referenceField"]?.Value;
        }

        public string ContentField { get; set; }

        public string FallbackContentField { get; set; }

        public string ReferenceField { get; set; }

        public override object ComputeFieldValue(IIndexable indexable)
        {
            if (string.IsNullOrEmpty(ReferenceField))
            {
                return null;
            }

            var referencedValues = GetReferencedValuesForField(indexable, ReferenceField);
            return referencedValues != null && referencedValues.Any() ? (object)referencedValues : null;
        }

        protected virtual IEnumerable<string> GetReferencedValuesForField(IIndexable indexable, string fieldName)
        {
            var sourceField = GetSourceField(indexable, fieldName);
            if (sourceField == null)
            {
                return null;
            }

            var ids = GetIds((string)sourceField.Value);
            return !ids.Any() ? null : GetReferencedValues(ids, indexable);
        }

        protected virtual IEnumerable<string> GetReferencedValues(IEnumerable<ID> referencedIds, IIndexable indexable)
        {
            var referencedValues = new List<string>();
            if (!(indexable is SitecoreIndexableItem indexable1))
            {
                return referencedValues;
            }

            var language = Getlanguage(indexable1);
            foreach (ID referencedId in referencedIds)
            {
                var referecedItem = GetReferencedItem(referencedId, indexable1.Item.Database, language);
                if (referecedItem == null)
                {
                    continue;
                }

                var contentValue = !string.IsNullOrEmpty(ContentField) ? GetFieldValue(referecedItem, ContentField) : null;

                if (string.IsNullOrEmpty(contentValue) && !string.IsNullOrEmpty(FallbackContentField))
                {
                    contentValue = GetFieldValue(referecedItem, FallbackContentField);
                }

                if (!string.IsNullOrEmpty(contentValue))
                {
                    referencedValues.Add(contentValue);
                }
            }

            return referencedValues;
        }

        protected virtual string GetFieldValue(Item item, string fieldName) => item.Fields[fieldName]?.Value;

        protected virtual IEnumerable<ID> GetIds(string fieldValue) => fieldValue
            .Split(new char[1] { '|' }, StringSplitOptions.RemoveEmptyEntries)
            .Where(ID.IsID)
            .Select(ID.Parse)
            .ToList();

        protected virtual Language Getlanguage(SitecoreIndexableItem indexable)
        {
            return indexable.Item?.Language;
        }

        protected virtual ID GetId(string id) => ID.IsID(id) ? ID.Parse(id) : null;

        protected virtual IIndexableDataField GetSourceField(IIndexable indexable, string fieldName)
        {
            return indexable.Fields.FirstOrDefault(field => field != null && field.Name.Equals(fieldName, StringComparison.OrdinalIgnoreCase));
        }

        protected virtual Item GetReferencedItem(ID id, Database database, Language language)
        {
            return database.GetItem(id, language);
        }
    }
  }

So with this bit of code we can now also use the resolved links feature with a fallback field, making it backwards compatible for us. Editors can keep on being lazy and fill in just the title - but they can overrule it if wanted and/or needed for the taxonomy to work.

Using the new code is the same as for the out-of-the-box resolvedlinks:

<sitecore>
  <contentSearch>
    <indexConfigurations search:require="solr">
      <defaultSolrIndexConfiguration>
        <documentOptions>
          <fields hint="raw:AddComputedIndexField">
            <field fieldName="F1" type="Sitecore.XA.Foundation.Search.ComputedFields.ResolvedLinks, Sitecore.XA.Foundation.Search" returnType="stringCollection" referenceField="Field1" contentField="title"/>
            <field fieldName="F2" type="Foundation.Taxonomy.Index.ResolvedLinksWithFallback, Foundation.Taxonomy" returnType="stringCollection" referenceField="Field2" contentField="taxonomytitle" fallbackContentField="title"/>
          </fields>
        </documentOptions>
      </defaultSolrIndexConfiguration>
    </indexConfigurations>
  </contentSearch>
</sitecore>

Once you move to SitecoreAI this becomes all obsolete, but for all those still working on Sitecore XM (with SXA - with or without JSS) this is hopefully still useful.


Friday, September 25, 2026

Sitecore SXA metatags

The Sitecore SXA metatags component

A small post on an issue I recently discovered with the SXA metatags component. This is in Sitecore & SXA 10.2 although it might very well be in the later versions as well.

To be honest, I still believe the issue is the content editor - but I have been in the business long enough to realize that sometimes we do have to make our solutions fool-proof.  And I can understand that not all content editors are familiar with all the do's and don't of creating perfect webpages.

So, what is the issue...  some content editors like to use special characters - most of them still harmless... until they decide to start using (double) quotes in the title of a page. This broke the "og:title" and other metatags and the seo monitors went off. 

Of course, they do not fill in the fields for the metatags as that is not really their cup of tea.


Sitecore SXA components - metatags

We are using a few of the out-of-the-box SXA components on the site, and one of them is the metatags component. It worked well for a long time - and still does - but this particular editor managed to break it. 

Adding quotes "" in a text that get injected in a html structure is not a good idea and apparently those characters are not encoded. 

According to another blog I found about non-ascii characters in the metatags, some characters like Japanse and such will be encoded - but not those that make the html invalid. 
 
Anyway, the component is using a view so we could easily intervene with actually just a small change. Not sure if what we did really is the best solution for everyone, but it worked for us and it might work for you as well. 

The view

@functions {
    private static string BuildAttribute(string attribute, string value)
    {
        return (!string.IsNullOrWhiteSpace(value) ? string.Format("{0}=\"{1}\"", attribute, HttpUtility.HtmlAttributeEncode(value)) : string.Empty);
    }
}

This is the new version of the BuildAttribute function inside the view. This is used for all the meta tags in the model so we cover all of them.  The only change is adding HttpUtility.HtmlAttributeEncode around the value. 


So after all, a small fix for an annoying issue that could as well have been resolved in content but as I said in the beginning - we can't always rely on content to be perfect.





Monday, September 7, 2026

Sitecore XP 10.5

Sitecore XP 10.5 - a need to upgrade story

First of all, this is not a guide with 10.5 features. Those have been written already a lot just after the release. It's also not an easy yes/no wizard that will tell you if you need to upgrade. Because the answer will always be "it depends" and I'm pretty sure company blogs will cover this. 
This is the story. The story of a customer who is in doubt which direction to take right now and who has several departments with different requirements and demands. I'm telling the story as I learned during my visits to several Sugcon events that this might sound familiar to quite some people in the Sitecore community.


The current situation

The customer a running their website(s) on Sitecore for a very long time already. We are almost at 20 years - of yes, they started in the v5 era. Of course, there have been upgrades and one complete make-over. Ever since that make-over they have been upgrading regularly to keep everything up-to-date. But things changed - within the company, with Sitecore and also within the whole internet business. Everything became headless, Sitecore turned to XMCloud and now SitecoreAI. And to make things worse the world got a few war and our American friends didn't help to make everything more stable. With a customer in the energy sector this makes it very hard to make big decisions - like moving towards a headless platform which in their case would mean a new website again as you do not want to try and shift a 10 year old website including a lot of legac content.
   
Over the past years we have been talking to them about this move. And the customer is convinced it is needed - but the time hasn't been right yet. But as we were going to do this, we also stopped upgrading as this is expensive and wouldn't bring them much new. At the moment they are running on the latest Sitecore 10.2 on Azure PAAS with SXA, EXM, Sitecore Forms, custom .net code and indexes on SearchStax. We are still talking about moving to SitecoreAI and they are really looking forward to that... but the realistic voice tells them it's not going to be ready and done before the end of next year. 

The upgrade

Support

Why is this important?  Because customers are/were looking at the extended support dates. On the Sitecore support site you can check all the dates when support will end for a certain version, and for 10.2 that is end of 2027. As budget planning for 2027 is due soon, these decisions are being made now.  

There is one more very interesting mention on that page that people might have missed. On June 1st 2026 Sitecore made a change to their support types. Might sound minor, but it is not if you see what has shifted in the extended support (years 3 to 6 after release date) from included to payed:
  • Assistance with production incidents
  • Security updates and fixes
For the IT department of our customer, (security) updates are a big reason to upgrade. So this is important for them. So next to remaining on support, they will be happy to see that in 10.5 quite a few things got updated to newer versions:

  • Windows Server 2025 (2022 still supported)
  • SQL Server 2025 (2022 still supported)
  • Solr 10 is now supported (and minimal), including Solr 10's mandatory Basic Authentication
  • .NET Framework for the platform itself is up to 4.8.1
  • Identity Server 9 runs on .NET 10
Next to that the security team will like the removal of outdated Javascript libraries and some significant security hardening. Note that especially the Solr is important here and needs some planning. It's a major change but as we are using SearchStax here it should not be an issue - just take into account this will be the first step to take.

Security effects 

Some of these security measures do have some impact. People upgrading should know that:
  • The GraphQL playground is removed. You can use other tools like Postman or something similar against the endpoint instead.
  • The package installer is disabled by default. It can be enabled again with the Sitecore.Packages.Disabled setting.

So far so good - IT team will be happy. 

Is there something in the upgrade for business people or editors?

The editor

There is. Do not expect new editors or any functional changes but there is a revamp or how Sitecore describes it:  
Sitecore XP 10.5 introduces a refreshed visual design across selected authoring experiences, including an updated color scheme and more consistent styling, with no functional changes to existing workflows.

Basically, the color scheme of SitecoreAI was set on the editors in Sitecore XP.  It's white and purple now but it will still work as the editors are used to. 



The modules

One important thing to consider in all of this is the use of Sitecore Experience Accelerator (SXA). At this moment - we are a few weeks after the release of 10.5 now - that module is not compatible yet. Meaning, there is no version for Sitecore 10.5 at this moment. It is mentioned on the release page that some modules (including SXA) are currently undergoing compatibility verification for Sitecore XP 10.5. Support for these modules will be introduced in upcoming module releases. If we check the compatibility matrix for the latest module support status we can see that there is no SXA for 10.5 yet - but we can be sure it is coming so it's a matter of time.  


And now?

The marketing department and the content editors of the customer will not be the drivers behind a new Sitecore upgrade here. The IT department however will be. Do they need to upgrade?

There are a few things to consider here. They are really considering moving to SitecoreAI. Actually, that is an understatement. They will move to SitecoreAI, they just don't know yet when. 
As we learned the new Sitecore version will not bring new features - unless you call new styling a feature. But that is nothing new. Most Sitecore customers on XM/XP are aware that they should not expect new features in new versions. It's all about support and (security) updates. Is this sufficient to do an upgrade? For some it will. 

Ok, enough vagueness. In our case for this customer the answer is yes. They always upgraded to remain supported and up-to-date, so the answer is yes - as soon as the modules are available. Upgrading now - hopefully really for the last time- is a good idea and will buy the time needed to do a proper transition to SitecoreAI.

I hope you learned something about Sitecore 10.5 and gained some insights in whether to upgrade or not. 



TL;DR

Remember, Sitecore support has changed policies and this might, should, will affect reasons to upgrade as for a long time now upgrades in the XM/XP sphere are triggered by compliance to support and security updates.