21

I have a scenario in a site we're building where there are groups of pages organized into folders for organizational purposes. However, the folders aren't pages themselves. Here's an example:

enter image description here

If someone navigates to http://site.com/mypage/components, they will get the typical "layout not found" Sitecore error:

enter image description here

Is there a typical or recommended way to handle this? Do you use 301-redirects to redirect requests for site.com/mypage/components to another page or do you override a processor to throw a 404 error/page?

  • In this particular case my question is why you would have your about page at /about/about-us instead of /about? Below I can see you have your blog landing page as /blog so it make sense with that. IF you feel that the site needs folders to group sub pages, maybe the end users would also benefit from a folder/category/listing page as well. – Kelly Brennan Oct 5 '16 at 21:00
  • There is no right or wrong answer to this. It really depends on what your business wants. Any answer would be very opinionated IMO. If the folders were to organise news items by date for example then there may be a clearer answer, otherwise it's a User Experience issue (i.e. would your user expect to be redirect to the homepage?) – jammykam Oct 5 '16 at 21:06
  • I updated the original post with a better example. The other was just something very quick, but probably too quick. :) – LonghornTaco Oct 5 '16 at 21:07
  • I updated the post with a better example... – LonghornTaco Oct 5 '16 at 21:08
  • sitecorenutsbolts.net/2015/11/30/… - I went with a 404 – Richard Seal Oct 5 '16 at 21:27
13

Both options are valid and more of a principal discussion. As the page hasn't ever existed, a 301 redirect (moved permanently) may not be the right option, but from a user perspective, the /about may (or may not) be redirected to most important item under that group.

a 404.0 (page not found) may the better option from a principal perspective, as, the page doesn't exist. Users may think that it's a badly build site, as a valid looking url results into a result that wasn't expected. (Is the site broken, do I miss information?). Especially because /about is part of the URL, and people tend to remove parts of the url to navigate through the site (well, I do ;)).

I would choose the 301 redirect in this case, for those "group" url's, as they are part of the url's of the subpages. I would use 404 for pages that really don't exist, like /About1, /bla, /huppeldepup

edit: as the question got changed as well ;)

for this example, using the hero slider content, I would choose for a 404, as it are url's that people shouldn't navigate to.

| improve this answer | |
9

If your items do not have any layout then they should throw a 404 error. You can update the LayoutNotFoundUrl setting to match your 404 page on your site so that the user is presented with a friendlier looking error page than the default Sitecore one:

<setting name="LayoutNotFoundUrl" set:value="/url-to/404" />

Using this setting there is no need to override any processors, as long as your 404 page correctly sets a 404 status code.

In your examples, the "Hero Slider Content" and the slides themselves are not navigable pages in their own right and only used in the context of the parent page (as datasource items) so browsing to any of those components should trigger a 404 to be thrown also (on the assumption that they too have no layout set).

| improve this answer | |
2

One way to handle this is to define a template or a field called something like "Exclude from URL" and then use a custom link provider and item resolver to skip these items when generating links and resolving requests. To correctly resolve items with this approach you do need to store the custom URLs somewhere though. One traditional approach is to store item-URL-mappings in the Sitecore IDTable triggered by a publish:end event, but using an index might be a better solution.

This was discussed quite a lot when Item Buckets arrived, for example by Alistair Deneys here.

| improve this answer | |
0

I would use 404 because for example /components is not a page and it should not be a part of an url. On the otherhand from SEO prospective 301 is not really valid in this case.

| improve this answer | |
0

I would not place non-page items under the start item in the first place. I usually create a "Shared Content" folder as a sibling to the Home item. Under this I would place non-page editorial content (Hero, Contact, FAQ etc.) and add them as data sources for components on a page.

In this way, the users will never be able to navigate to the data items, and thus never get a "Layout Not Found" error page.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.