Cannonical
Cannonical
Cannonical should be the main absolute URL to the page. This is in order to have several different locations for the same information/page but only one is really the "one".
Should preferably be absolute and put in <head>, example:
<link rel="canonical" href="http://dannejaha.se/original-url.html">
If you want to keep track on the cannonical URL while developing include the following code snippet. This will write the cannonical and current URL at top of every page so you can check if its correct without having to open source code.
At top of you _layout (or other base view):
<div class="canonmock">
</div>
<div class="canonmock2">
</div>
Then add the following javascript:
$(function () {
$('.canonmock').html('C:' + $('head link[rel=canonical]').attr('href'));
$('.canonmock2').html('L:' + location.href);
});
This requires jQuery if you dont have it included you may use CDN, like this:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
Published: 2016-08-25