WebAndMobile starter kit duplicates meta description and no title
Hello,
I am using U7, with WebAndMobile starter kit.. Upon checking the source html after rendering in any browser, I find the meta desription tag is duplicated and no title tag...
I think the "metatags.cshtml" scripting file is the suspect, but since I am an umbraco noob, I am at an impass.
In the following code, stepping through, as the conditional that checks 'Parameter.metaType' it is ALWAYS BLANK..?
Here's the current code for "metatags.cshtml":
@{
var page = Model;
var itemsPerPage = Parameter.metaType;
var metaTitle = page.metaTitle;
var metaDescription = page.metaDescription;
foreach(var level in page.Ancestors())
{
if(metaTitle.ToString() == string.Empty)
{
metaTitle = level.metaTitle;
}
if(metaDescription.ToString() == string.Empty)
{
metaDescription = level.metaDescription;
}
}
if (Parameter.metaType == "metatitle") //<== Parameter.metaType is always blank, no matter what
I just installed the skin on a fresh 7.1RC and the above behaviour appears to be a bug in the package.
I'm not sure why "title" is never rendered but if it was it would also be displayed twice since the same macro is being called twice with different parameters and the logic in the code simply does not work.
I suggest you go to your master templates (desktop and mobile) and remove the calls to the "metaTags" macro and insert these umbraco fields instead.
That way the title and description are written to the source and if both fields are empty nothing is ever output to the source.
One could of course also just fix the Razor macro so it works but it's running late and I'm too tired to digg into the dynamic razor implementation.
In the "Settings" section go to the "templates" folder and find the masterpage (At least I think it was the masterpage where I found this) and then you have a toolbar in the template editor where you can insert
Just place them where the macro call currently is placed.
I hope this makes any sense.
Sorry if there is something I can't remember but the local installation I made has been trashed some weeks ago :)
I finally figured out the problem.. I researched a bit and discovered that 'Parameters' is/are the parameters added under 'Developer/Macros/Meta Tags' there was no parameter for 'metaType', and therefore, the 'metaType ' attribute in the templates at 'settings/templates' at lines 52-53:
were never able to be accessed by the razor script. I added a parameter called 'metaType' with a type of textbox under the 'parameters' tab of the 'Meta Tag' macro and voila, presto, shazam...
WebAndMobile starter kit duplicates meta description and no title
Hello,
I am using U7, with WebAndMobile starter kit.. Upon checking the source html after rendering in any browser, I find the meta desription tag is duplicated and no title tag...
I think the "metatags.cshtml" scripting file is the suspect, but since I am an umbraco noob, I am at an impass.
In the following code, stepping through, as the conditional that checks 'Parameter.metaType' it is ALWAYS BLANK..?
Here's the current code for "metatags.cshtml":
@{
var page = Model;
var itemsPerPage = Parameter.metaType;
var metaTitle = page.metaTitle;
var metaDescription = page.metaDescription;
foreach(var level in page.Ancestors())
{
if(metaTitle.ToString() == string.Empty)
{
metaTitle = level.metaTitle;
}
if(metaDescription.ToString() == string.Empty)
{
metaDescription = level.metaDescription;
}
}
if (Parameter.metaType == "metatitle") //<== Parameter.metaType is always blank, no matter what
{
<title>@metaTitle</title>
}
else
{
<meta name="description" content="@metaDescription"/>
}
}
All my pages have titles and descriptions and the original dev who made this is unresponsive to emails.
Ideas, please?
Hi Beau
I just installed the skin on a fresh 7.1RC and the above behaviour appears to be a bug in the package.
I'm not sure why "title" is never rendered but if it was it would also be displayed twice since the same macro is being called twice with different parameters and the logic in the code simply does not work.
I suggest you go to your master templates (desktop and mobile) and remove the calls to the "metaTags" macro and insert these umbraco fields instead.
That way the title and description are written to the source and if both fields are empty nothing is ever output to the source.
One could of course also just fix the Razor macro so it works but it's running late and I'm too tired to digg into the dynamic razor implementation.
Hope this helps.
/Jan
Hey, thanks for the response.
"These Umbraco fields"... I'm not sure what you mean. Was there missing info on that reply?
I saw in the razor where it seems to be bombing, but I'm total-noob in Umbraco, so therefore useless in this respect, currently...
Hi Beau
In the "Settings" section go to the "templates" folder and find the masterpage (At least I think it was the masterpage where I found this) and then you have a toolbar in the template editor where you can insert
Just place them where the macro call currently is placed.
I hope this makes any sense.
Sorry if there is something I can't remember but the local installation I made has been trashed some weeks ago :)
/Jan
Oh ok, cool. Good to know.
I finally figured out the problem.. I researched a bit and discovered that 'Parameters' is/are the parameters added under 'Developer/Macros/Meta Tags' there was no parameter for 'metaType', and therefore, the 'metaType ' attribute in the templates at 'settings/templates' at lines 52-53:
<umbraco:Macro metaType="metatitle" Alias="MetaTags" runat="server"></umbraco:Macro>
<umbraco:Macro metaType="metadescription" Alias="MetaTags" runat="server"></umbraco:Macro>
were never able to be accessed by the razor script. I added a parameter called 'metaType' with a type of textbox under the 'parameters' tab of the 'Meta Tag' macro and voila, presto, shazam...
is working on a reply...