Remove /home/ from URL
k
Hey everyone, I'm always using this scheme for CMS: website (root node) - home - some category - another category - etc Up to Umbraco 8 it was possible to put a domain as a hostname for the home page, which would render that node to be accessible directly without /home/ path. It seems that doesn't work in Umbraco 10, if I do it, other pages on the same level cannot be accessed with an error "This document is published but its URL cannot be routed". Any idea what would be the best way do to that with Umbraco 10?
d
Hi there! We use the exact same layout for all our websites. What we do, is we configure the domain on the root node and add a special property to the root node: "umbracoInternalRedirectId". We select the homepage in that field to render the homepage in the place of the website root: https://docs.umbraco.com/umbraco-cms/reference/routing/routing-properties#umbracointernalredirectid
I also created a controller for homepage that checks if the homepage is accessed directly or through an internal redirect and if users access the homepage directly, I redirect them to the root like so:
Copy code
csharp
// Business rule: homepages are only visited through internal redirects
//    (read: only accessed through the root node)
if (!UmbracoContext.PublishedRequest!.IsInternalRedirect)
{
    // current page should never be null, nor should its root ever be null,
    //    so we ignore that on purpose.
    return RedirectPermanent(CurrentPage!.Root()!.Url());
}
s
I've seen lots of sites like this. Out of interest what benefit do you find for structuring content like this? When I train users I explain the URL should give the tree location of the node you're looking for. /news/somecategory/my-news-article. Is easy to find. So "/" will be the root - e.g. home node. Only advantage I can see is if you use usync or similar and publish - avoids editors accidentally publishing all children?
d
Our experience is that content editors find it confusing if the homepage and the header and footer and technical website stuff is on the same node. Therefore, we separate the homepage content from the "global" content and the "technical stuff". The root node is generally a thing that content editors can ignore and that appears to be helpful
What I mean to say is that it allows content editors to focus on content without getting distracted by other things. It reduces cognitive load
k
We use a different root node for non-browsable content, e.g., headers, footers, data. Then the browsable content tree works as normal, and all other stuff is not mixed with it. No code and no special culture&hostnames setup needed.
s
This is how I do it. Global Setttings. And a seprate "site settings" for "developer only" settings.
n
I typically follow a similar approach to @D_Inventor , from my perspective I had a spate of clients wantting to be able to temporarily replace their home page for some specialist campaigns. By using the routing property it allowed the home page to be "picked" by an editor.
k
That's an interesting take. Not sure how this would be done using the "separate root" approach. Thanks for sharing!
11 Views