0
votes

I currently have these Document Types:

Master
    Home
    News
    About

I allow Home at root, so when I visit / it will show my home, instead of going to /home. Then I create a new Content for Home. That means my Content/page layout looks like this:

Home
    News
    About

Since I want all my pages to be /news and /about, but still have / be my Home, I therefore allow News and About to be children of Home (in the permissions tab). This is great and all, because I can then create properties on my Home Document Type, which the other document types will inherit (such as SEO).

Well, both great and bad. If I want my Home page to have properties that none of the other pages will inherit, I cannot do that now, because all the other pages inherits from my Home Document Type.

How am I supposed to achieve this:

  • Have a Master.cshtml file, which has @RenderBody()
  • Make a property on Home which will not be inherited by all the other Document Types
  • Make sure / is my Home content page

The only way I can think about this, is by allowing my Master Document Type at root, then replace my Home Document Type with Master and have the same structure as now, but basically have Home as a child of Master (in the content page). This would mean / is set to the Master content page, which I do not want. However, URL rewriting /home to / should solve my issue, right?

Is there a better way? Is this the way to go? Let me know how you guys would structure a page like this, so I can create properties for all pages and while separating Home from the rest of the pages.

Thanks!

2

2 Answers

2
votes

You should use composition of document type instead of "nested inheritance". This new feature has been made exactly to solve this kind of problem:

You can add to every document type the SEO document type to add the SEO tab, but add some specific properties only to some document types. No need to change the tree in the content section.

For example you can create these document types:

  • seo (only used for composition in other document types)

  • shared (only used for composition in other document types)

  • home (with composition of seo + shared ) + some specific fields for this document type

  • news (with composition of seo + shared) + some other specific fields for this

  • about (with composition of seo and no need for the shared for this particular document type)

Note that these are flat on the document type tree and there is no need for master document type because you will add everything in common via composition and not inheritance.

The content tree will look exactly the same:

Home
    News
    About

Take a look at http://letswritecode.net/articles/document-type-compositions-in-umbraco/ for some examples

1
votes

One approach would be to use an Umbraco internal redirect to display the Home page content whenever the root / URL is requested.

Add a new Content Picker property to your Master DocumentType and give it the alias umbracoInternalRedirectId. This is a reserved property alias, much like umbracoNaviHide and umbracoRedirect, and it will cause the selected page's content to be displayed without performing a URL redirect.

enter image description here

On your Master page select the Home page using your new property. Now whenever you browse to / the Home page content will be displayed.

enter image description here

Your Home page will still be accessible via the /home URL so you should either use a canonical tag to prevent duplication of content or you could implement a URL rewrite from /home to /.