I would like to delete the Home from master database. I can delete without any problem but I saw for example references in site configurations. Is there any other places where should I remove the references?
3 Answers
It is safe to delete the default Home item. I have done so on many projects.
The only place where you need to update the reference is the default site definition:
<site
name="website"
...
rootPath="/sitecore/content"
startItem="/home"
... />
Some system sites, such as "shell" and "modules_website", also have references to the Home item. In most cases they won't be used, but it's still best to change them to point to an existing item.
-
Unfortunately that's not enough. Sitecore assemblies maybe use the startItem and contentStartItem, and if it's not existing maybe things can go wrong. For example the
Sitecore.UiUtil
GetHomeItem
method uses and checking the length of it. Nov 10, 2016 at 9:55 -
@TRNKTMS What are the circumstances in which this becomes a problem? Nov 10, 2016 at 10:43
-
When I try implement this functionality - jammykam.wordpress.com/2014/04/24/…. To inject js/css into Content Editor. If I don't remove the contentStartItem for the
shell
site then it does not injecting the script. Strange but works like this... Nov 10, 2016 at 10:49 -
1@TRNKTMS: I never had issues with that... but makes sense to change it since the
shell
site hasmaster
set as the content database.– jammykamNov 11, 2016 at 9:32
You need to check the default site definition and your custom site definition nodes in the config file. It must not include /home path as start path and master as a database.
You don't need to care about modules_website as it is not using the Master database.
And regarding the Sitecore.UIUtil.GetHomeItem method, it won't create any issue. If it can't find the path /sitecore/content/Home it will return the Item till /sitecore/content.
-
Sitecore.UIUtil.GetHomeItem
could issue if thecontentStartItem
is not an existing item because then it returns with null and it's checking the length of the setting -if (obj == null && site.ContentStartItem.Length > 0)
. Nov 10, 2016 at 14:15
I would like to answer my own question because I found out and tested the exact answer. Of course thank you for the answers. So here is the patch configuration what I used to remove all references to the default Home item from the default Sitecore configuration.
<sitecore>
<settings>
<setting name="DefaultItem">
<patch:attribute name="value">/</patch:attribute>
</setting>
</settings>
<sites>
<site name="shell">
<patch:attribute name="startItem">/</patch:attribute>
<patch:attribute name="contentStartItem">/</patch:attribute>
</site>
<site name="modules_website">
<patch:attribute name="startItem">/</patch:attribute>
</site>
<site name="website">
<patch:attribute name="startItem">/</patch:attribute>
</site>
</sites>
</sitecore>