First Month With Sitecore
Over the past month, Sitecore has been my main focus at my job, learning the ins and outs, and figuring out proper standards and fixing errors caused by my inexperience with the platform. In this post, I will be going through the mistakes that I personally made and what I learned and hopefully things to look out for when using Sitecore.
Mistakes I Made
Making sure you have the correct version of your library references in Visual Studio is a must, Sitecore may not even run if you use newer versions of specific libraries, follow along and make sure you have the correct versions. Below is an example of a common error made when creating Sitecore components.
In the highlighted field in the photo above, this library uses version 188.8.131.52, if you create a solution from Visual Studio, this file it actually on newer versions, I’d recommend checking your sitecore’s web.config file to make sure your versions match with the dependencies needed.
Using the wrong version can easily result in your Sitecore instance not loading. Note that the versions might change as Sitecore updates, always check what versions you are using and make sure they do not conflict with each other.
If you are using the Sitecore Helix architecture you may have multiple Visual Studio projects with multiple web.config files, you do not want to overwrite your sitecore’s web.config file (found in the inetpub/wwwroot/website folder). If you do sitecore will blow up in your face, luckily with your sitecore download files, they should have a Web.config file you can copy over in case you do overwrite it. However, if you do not fix it, you will have to grab that file every time you build and deploy your project, thankfully to prevent this issue, there is a simple solution. Check on the screenshot below.
This web.config file is created whenever you create a new Visual Studio Project, to make sure you do not overwrite your Sitecore’s web.config match the option for the highlighted section. You must do this for every project you create.
This becomes more of an issue as you begin to add more components to your solution, but make sure you are using the correct Framework for your overall solution. To make sure it is correct head to a project in your solution, right click the project and click “Properties” make sure you match the versions with other components in your solution. This is also important if you copied a project and are reworking it into something else since it lets you change the name of your Default Namespace and Assembly Name. Below is a screenshot of the “Properties” Window.
The highlighted text are the parameters that might require changes, if everything looks correct to you just leave it and do not touch it.
What I Learned and Things to Look out For
Since you’re working in Visual Studio and Sitecore you need to be able to be able to give proper naming when it comes your files, fields, and parameters as they are the means of linking together Sitecore with C#. I made the mistake of naming a field slightly different than what i had in the model of my Sitecore project, it gave me a good amount of headache. Below is a screenshot showing the correlation between your field names in Sitecore and your C# code.
The two highlighted sections Video ID has the same naming convention as it would appear in your model in your code, make sure you keep your naming the same or else it will cause errors.
In Sitecore, you need to create proper linking between your template, rendering, and content to be able to display it on a page, if one of the fields is missing you might run into issues that become difficult to track down with little experience. Below is an example in your rendering for your component making sure you set the proper link to your template.
There are probably a lot of things I missed in this post, but the most important thing is that learning everything about Sitecore does not happen overnight, it is gradual. For new developers, it is important to take in what you can, and ask questions if you are stuck, spending an hour on a potentially simple solution isn’t good use of your time. Sitecore is also a pretty steep learning curve so it’s ok to feel a bit lost, keep persistent and with time you will feel more comfortable with the process.
Thanks for taking the time to read this post, it’s pretty wordy so I hope you enjoyed what you read.