Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If Sitemap description is left empty it takes the value of Sitemap title attribute #238

Closed
pradeepn opened this issue Oct 17, 2013 · 2 comments

Comments

@pradeepn
Copy link

Hi,
In the sitemap, if i left the sitemap description attribute to empty or if it is not added in the node in sitemap file, Instead of getting the sitemap description as null or empty i am getting the title value.

    <mvcSiteMapNode title="About" description="" controller="Home" action="About"/>

SiteMapTitleHelperModel.cshtml

<strong>@Model.CurrentNode.Title</strong><small>@Model.CurrentNode.Description</small>

In the small tag i am getting the Title value if i left empty or if didn't have description attribute. If i have some value for description i am getting correct value.

Thanks.

@NightOwl888
Copy link
Collaborator

Going back a bit, there was an inconsistency in this behavior between the XmlSiteMapBuilder and ReflectionSiteMapBuilder. The solution then was to make them both use the description by default if the title wasn't provided. At the time I didn't make an issue of it because I figured it would be more SEO friendly by default (by populating the description - and title attribute of the HTML anchor tag - automatically when it isn't provided).

In hindsight, it probably would have made more sense not to default the description during the time the SiteMap is constructed, but instead make the description default to title in the default HTML helper template so it can be changed more easily if it isn't the behavior that is desired.

This isn't tough to fix, but it would be a breaking change for anyone using custom HTML helper templates and could have drastic implications on their SEO site positioning if they are. If we follow semantic versioning to the letter, we would have to bump the major version number because of the potential impact of this change. In other words, I agree with you but can't fix this until version 5.

I suggest for the time being you add some logic to your HTML helper template to check whether the values of @Model.CurrentNode.Title and @Model.CurrentNode.Description are the same and if so, to not output the description in this case. As long as your description is always at least slightly different than title (including a change in casing or a space or period at the end), you will get the description in your output.

if (@Model.CurrentNode.Title == @Model.CurrentNode.Description)
{
    <strong>@Model.CurrentNode.Title</strong>
}
else
{
    <strong>@Model.CurrentNode.Title</strong><small>@Model.CurrentNode.Description</small>
}

@pradeepn
Copy link
Author

Hi,
Thanks, That's exactly how i managed it till now. Some times due to the SitemapActionFilter attribute the condition got broken and i am seeing the static xml title value in description.

But any way. I can live with this. If its know issues then it is fine. I can understand your point.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants