sitecoreSitecore query syntax


Template Names vs. Template IDs vs. Item Names in Queries:

I strongly recommend that you use Template IDs and not Template Names or Item Names in your queries. This will ensure that your queries will still work, even when templates and/or items are renamed.

The one exception to this is when working with OOTB templates, while querying an OOTB structure, e.g. /sitecore/content or /sitecore/system/Marketing Control Panel. In these situations, the loss of readability is often greater than the risk of queries breaking, since these templates are far less likely to be renamed.

Note that template names were used in my examples, above, for sake of readabiltiy. Those queries should not be used in production, unless the template names are replaced with template IDs.

Reference Sheet:

I noticed that the Sitecore Query Cheat Sheet is no longer available for download on the web (all of the Sitecore-hosted links now redirect to 404 pages). Fortunately, I had a copy on my machine, and have added a screenshot, below:

Sitecore Query Cheat Sheet