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.
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)
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. :)
Rich Text Editor for Meta Description Tag
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.
Hi Brian
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:
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
Other Umbraco Helpers detailed here:
https://our.umbraco.org/documentation/reference/querying/umbracohelper/
regards
marc
Marc,
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. :)
Brian
is working on a reply...