How do i stop people navigating to a page by node Id? i.e. 1109.aspx
Hi
From a SEO point of view there are 2 visible routes to the same page.
/my-page
and
/1109.aspx
They both render the same page? I want only to allow the /my-page to render the page. Is there something i can do to stop the id number of a page from actually rendering a page?
Crawling a site with an SEO audit flags these up as a bad thing so i would like to get rid of them.
Or am i missing something? Is this an intended action?
How would i firstly detect the preview page, and how would i build up the de facto cononical tag? Instead of Model.Url should i use Model.Name, but how would that work when the url is within a few different sub folders?
The link from above mentioned how to detect preview mode:
Umbraco.Web.UmbracoContext.Current.InPreviewMode
However, if you are doing the canonical URL approach, you have no need to detect preview mode. Just get the URL for the page, which should be something like this:
var canonicalUrl = Model.Content.Url;
I believe that would work in the latest version of Umbraco (7.4.3). Which version are you using?
How do i stop people navigating to a page by node Id? i.e. 1109.aspx
Hi
From a SEO point of view there are 2 visible routes to the same page.
/my-page
and
/1109.aspx
They both render the same page? I want only to allow the /my-page to render the page. Is there something i can do to stop the id number of a page from actually rendering a page?
Crawling a site with an SEO audit flags these up as a bad thing so i would like to get rid of them.
Or am i missing something? Is this an intended action?
Thanks for your help in advance. Neil.
I believe those URL's may be used when previewing content. What you could do is detect those URL's in your main layout CSHTML file and redirect away (e.g., to the full URL). However, you would probably want to do that only when you aren't in preview mode: https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/73972-detecting-preview-mode-in-umbraco-7#comment-237079
Alternatively, you could inject a canonical tag that indicates which URL is the de facto one that should be crawled: https://moz.com/blog/canonical-url-tag-the-most-important-advancement-in-seo-practices-since-sitemaps That has the advantage that it won't adversely affect preview mode.
Hi
Ive found this, but it doesnt suggest how to detect if the page being viewed is a preview page.
How would i firstly detect the preview page, and how would i build up the de facto cononical tag? Instead of Model.Url should i use Model.Name, but how would that work when the url is within a few different sub folders?
Cheers Neil.
The link from above mentioned how to detect preview mode:
However, if you are doing the canonical URL approach, you have no need to detect preview mode. Just get the URL for the page, which should be something like this:
I believe that would work in the latest version of Umbraco (7.4.3). Which version are you using?
Using 4.11.0
Just checking the output now. my bad!
it's outputting the de facto cononical tag now :)
I'll use this approach as it's for the SEO audit guys and think that's all they need it to do.
Thank you very much for your help!
is working on a reply...