Sitecore Experience Editor Multisite Errors

I recently migrated a website from Umbraco to a multisite Sitecore 9.0 u1 instance. When I used Experience Editor to edit a page, I received an unpleasant surprise.

The sc_site parameter was in the url as expected, but when I tried to use editor commands like "edit component properties" or "change the associated content", the Experience Editor would redirect to the default website home page. Looking at the logs I saw the dreaded "Layout not found" error being thrown. Not good!

The fix turned out to be a simple one, so I thought I would share it. I had the following meta tag in my shared layout:

<base href="/">

The HTML <base> tag is used to specify a base URI, or URL, for relative links. For example, you can set the base URL once at the top of your page in header section, then all subsequent relative links will use that URL as a starting point. The problem is, this tag causes some SPEAK commands to improperly reference the base website instead of Sitecore shell.

The solution is to prevent this tag from rendering in the Experience Editor:

@if (!Sitecore.Context.PageMode.IsExperienceEditor)
{
    <base href="/">
}

Hope this saves someone out there a bit of troubleshooting time.

~David


 

Add comment

Loading