Optimize Your Sitecore Development with This CheatSheet

mug with a cheat sheet

As a Sitecore developer, you know that time is always of the essence when it comes to building and maintaining websites. Whether you’re working on a new project or troubleshooting an issue, having quick access to the most frequently used commands and syntax can be a game changer.

You know that developers love a good Cheat Sheet.

And since I started working with Sitecore I’ve been taking notes of the commands that I use every day. Then I think “why don’t I share it with the community”? So I improved my list of commands and created this Cheat Sheet with the most used commands in Sitecore XP 10.3.

With a comprehensive list of commands for Sitecore HTML Helper, xConnect API, Docker, and Sitecore CLI, you can streamline your development process and speed up your workflow.

So I created a PDF file with my Cheat Sheet:

Feel free to download and use it:


What are the commands and why have I chosen those topics?

If you don’t wanna to download the PDF file, here are all the commands contained in the Cheat Sheet and the answers for each topic as well:

1) Sitecore HTML Helper

If you’re a Sitecore developer you will likely build components. And build components mean create Views. So here you have a huge list with the most used Sitecore HTML methods helper that you’ll use frequently.

CommandDescription
@Html.Sitecore().Field(“FieldName”)Renders the field with the specified name on the current item
@Html.Sitecore().Field(“FieldName”, YourItem)Renders the field with the specified name on the provided item
@Html.Sitecore().Field(“FieldName”, new { Text = “Default Text” })Renders the field with the specified name on the current item with the provided default text
@Html.Sitecore().Field(“FieldName”, new { DisableWebEditing = true })Renders the field with the specified name on the current item with web editing disabled
@Html.Sitecore().Field(“Image”, YourItem)Renders the image field with the specified name on the provided item
@Html.Sitecore().Field(“Image”, YourItem, new { w = 300, h = 200 })Renders the image field with the specified name on the provided item with the specified width and height
@Html.Sitecore().Field(“Link”, YourItem)Renders the link field with the specified name on the provided item
@Html.Sitecore().Link(“FieldName”, YourItem)Renders the link field with the specified name on the provided item
@Html.Sitecore().BeginField(“FieldName”, YourItem)Begins a field with the specified name on the provided item
@Html.Sitecore().EndField()Ends the current field started by BeginField
@Html.Sitecore().Rendering(“{ItemID}”)Renders the rendering with the specified ID
@Html.Sitecore().Rendering(“{ItemID or Name of the Rendering}”, new { DataSource = “{Item ID}” })Renders the rendering with the specified Item ID or name on the item with the specified ID. Also, adds a default datasource.
@Html.Sitecore().CurrentRenderingGets the current rendering from Context
@Html.Sitecore().RunPipeline(“Your-Pipeline”, your-parameters);Used to execute a specific Sitecore pipeline, passing in any necessary data as parameters.
@Html.Sitecore().Placeholder(“YourPlaceholder”)Renders the specified placeholder
@Html.Sitecore().DynamicPlaceholder(“YourPlaceholder”)Renders the content of the specified dynamic placeholder
@Html.Sitecore().FormHandler(“Your-Form-Name”, “Your-Submit-Button”)Used to handle form submissions. used to specify the handler for a form with the name “Your-Form-Name” and the action “Your-Submit-Button”. When the user submits the form, Sitecore will execute the specified action, in this case, “Your-Submit-Button”.
@Html.Sitecore().CurrentItemGets the current item
@Html.Sitecore().ViewRendering(“path”, new { Title = “Your Title”, Description = “Your Description”})Render a view statically. The first parameter specifies the path to the view, and the second parameter passes data to the rendering.
@Html.Sitecore().ControllerRendering(“controller name”, “action name”)Render a controller statically. It executes a controller action and renders the result. The first parameter specifies the name of the controller, and the second parameter specifies the name of the action.
@Html.BeginEditFrame(“My Edit Frame”, YourItem, “Edit Frame Description”, new { Buttons = “save, cancel” })Begins an edit frame for the provided item with the specified name, description, and button options. Include Glass Mapper lib.
@Html.Sitecore().VisitorIdentification()Renders the visitor identification tag
@Html.Sitecore().IsExperienceEditorEditingGets a boolean value indicating whether the current request is being executed in Experience Editor mode
@Html.Sitecore().HasValue(“FieldName”, YourItem)Gets a boolean value indicating whether the specified field on the provided item has a value
Section 2: xConnect

xConnect is an essential component of Sitecore XP that allows you to collect, store, and access customer interaction data from various sources. Here I bring the most important xConnect commands for communicating with the xConnect API, where you can check if xConnect is Working, check Contacts, Facets and Interactions.

MethodURLDescription
GEThttps://your-xconnect-url/Returns a timestamp indicating that xConnect is working.
GEThttps://your-xconnect-url/odata/$metadataReturns the metadata document that describes the structure of the xConnect data service. This can be used to query the available entity types and their properties.
GEThttps://your-xconnect-url.com/odata/contactsRetrieves a list of all contacts in xConnect.
POSThttps://your-xconnect-url.com/odata/contactsInsert a new contact in xConnect.
GEThttps://your-xconnect-url.com/odata/contacts/{your-contact-id}Retrieves information about a specific contact identified by their contact identifier
GEThttps://your-xconnect-url.com/odata/contacts/{your-contact-id}?$expand=your-facetRetrieves a specific facet for a given contact identified by their contact identifier
POSThttps://your-xconnect-url.com/odata/contacts({you-contact-id})/your-facetInsert new data for the specific facet for a given contact identified by their contact identifier
GEThttps://your-xconnect-url.com/odata/interactionsRetrieves a list of all interactions in xConnect
POSThttps://your-xconnect-url.com/odata/contacts({your-contact-id})/interactionsInsert a new interaction in xConnect for a given contact identified by their contact identifier

Section 3: Docker

Docker is one of the new features of Sitecore XP 10. Docker is a powerful tool for managing containers and simplifying the deployment process for Sitecore XP. You can easily build, run, and manage Docker containers for your Sitecore sites, without the need for complex command-line syntax.

Some of the most useful Docker commands include building Docker images, running Docker containers, and connecting to the Sitecore instance running inside a Docker container. s needed for your specific site configuration.

CommandDescription
docker buildBuild a Docker image from a Dockerfile
docker helpList all available commands
docker containerManages Docker containers, including starting, stopping, and removing them.
docker execExecute a command inside a running Docker container
docker imagesLists all the Docker images on the local machine.
docker infoDisplay high-level information for your Docker environment (version, root directory, default isolation mode, and so on)
docker inspect <image>Returns low-level information of the image
docker networkManages Docker networks, including creating and removing them.
docker psList running Docker containers
docker pullDownloads the latest version of a Sitecore Docker image from Docker Hub.
docker rmRemove a Docker container
docker runStart a new Docker container
docker start <container>Starts a stopped Docker container.
docker stop <container>Stop a running Docker container
docker system pruneRemoves all stopped containers, dangling images, and unused networks and volumes.
docker volumeManages Docker volumes, including creating and removing them.
docker-compose buildBuilds a new Docker image from the specified docker-compose.yml file.
docker-compose downStops and removes the Docker containers specified in the docker-compose.yml file.
docker-compose down –volumesStops and removes Docker containers, networks, and volumes created by docker-compose up.
docker-compose execRuns a command inside a running Docker container.
docker-compose logsDisplays the logs of the running Docker containers.
docker-compose psLists the running containers defined in the docker-compose.yml file.
docker-compose restartRestarts Docker containers.
docker-compose runRuns a one-time command against a service.
docker-compose startStarts stopped Docker containers.
docker-compose stopStops running Docker containers.
docker-compose upStarts the Docker containers specified in the docker-compose.yml file.
docker-compose.ymlThe main configuration file used by the docker-compose command. It contains information about the different containers (referred to as services) and their configuration.
.envThis is an environment file. The values here provide default values for any environment variables referenced in the Compose file, or you use it to configure Compose.
.\Clean.ps1Clean the data of the Sitecore Docker instance
.\Init.ps1Initialize and prepare the environment for running a Sitecore Docker instance
.\Start.ps1Build and initialize Sitecore Docker images
.\Stop.ps1Stop a Sitecore Docker instance
Section 4: Sitecore CLI

Sitecore CLI is a command-line tool for managing Sitecore XP installations, making it easier to automate common tasks and streamline your development workflow. You can quickly access the most frequently used Sitecore CLI commands, allowing you to save time and avoid errors.

Some of the most important Sitecore CLI commands in the Cheat Sheet include installing Sitecore, deploying Sitecore, and managing Sitecore packages.

sitecore indexAutomates indexing operations. Install the indexing plugin to access this command.
sitecore initInitializes a project configuration in the current folder.
sitecore itemresCreates an item package in a resource file with configurable options. Install the Items as Resources plugin to access this command.
sitecore loginLogs in to a Sitecore instance.
sitecore pluginManages plugins for the CLI that contain additional commands..
sitecore publishPublishes all content from the Master database to the Web database. Install the publishing plugin to access this command.
sitecore ser, serializationHandles the serialization of items. Install the serialization plugin to access this command.
sitecore connectConnect your environment to a different existing environment and use its login information.
sitecore edgeHelps you manage Experience Edge API keys.
sitecore dbcleanupPerforms database cleanup according to the provided tasks.
In summary…

Having a Cheat Sheet can be a major time-saver and productivity booster for any developer. With quick access to the most frequently used commands for rendering, xConnect, Docker, and Sitecore CLI, you can spend less time searching for the correct syntax and more time building great websites. Whether you’re a seasoned Sitecore developer or just getting started, a Cheat Sheet can be an invaluable tool for streamlining your workflow and making your development process more efficient.

Find a typo or something wrong? Would you like to improve this Cheat Sheet? Get in touch with me!

Leave a Reply

Your email address will not be published. Required fields are marked *