Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi, I am wondering if anyone has run into the issue of using a rich text editor that they are putting content into for their meta description for SEO. The problem I am running into is that all of the HTML tags and links are coming along for the ride, and I don't necessarily want this to be occurring. Is there an elegant way to just get the text from the rich text editor.
Calling .ToString() gives me an ugly looking meta description.
<meta name="twitter:description" content="@umbraco.library.RemoveFirstParagraphTag(Html.Raw(pageVariables.copy).ToString())">
I tend to use a text area for these meta descriptions, so that I'm not putting html inside the content attribute of a meta tag, however...
There is an UmbracoHelper method called StripHtml that you could use to remove the html you do not want here:
@Umbraco.StripHtml("<blink>Stop the blinking</blink>");
and you may also want to limit the number of characters of the description that gets written into the content attribute, if so there is also a Truncate method on the UmbracoHelper... eg
@Umbraco.Truncate("I wish I was a tweet, at least then I get 140 chars", 10, true)
Other Umbraco Helpers detailed here:
Thanks so much for your quick response. This is exactly what I was looking for, and this allows me to leave my underlying Umbraco structure unchanged. Win. :)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted