I have a problem when using special characters in meta and alt text in Umbraco.
I am testing with Meta description and Alt text like this: Test test æøå
And it generates this output:
<meta name="description" content="Test test æøå">
<img src="#" alt="Test test æøå" />
If I insert the same text in title tags and normal content, then the output is just perfect.
The code that is generating the meta and title tags looks like this:
<!DOCTYPE html>
<html lang="da">
<head>
<meta charset="utf-8">
<meta name="description" content="#Umbraco.Field("pageDescription")">
<title>#Umbraco.Field("pageTitle")</title>
</head>
The files are saved as utf-8 using Notepad++.
If I insert æøå directly in the HTML, then it shows æøå without any problems.
I have also tried this:
<p>#Umbraco.Field("pageDescription")</p>
And then it shows "æøå" correctly.
Does anybody know what I am doing wrong?
Thanks in advance!
// René
Looks like this is a "feature" of Razor that it will always HTML encode attributes. See: Razor - #Html.Raw() still encoding & in meta tag attributes
So to work around this, you can do the following:
<meta name="description" #Html.Raw("content=\""+ #Umbraco.Field("pageDescription") + "\"") />
<title>#{ var title = new HtmlString(Umbraco.Field("pageTitle").ToString());}#title</title>
It's not pretty, but it works.
Related
I have the following html page which i share on facebook
<head>
...
<meta property="og:title" content="my title" />
<meta property="og:description" content="" />
...
</head>
...
I don't want the og:description in my shared link.
When i removed the og:description tag, it filled the description part from my post body. this also occurred when i set it's value to an empty string or space.
How can i make it work with empty og:description?
Use HTML Escape Characters
The meta field og:description is mandatory. When it's empty the default behavior is to fill it up with text from the page's <body>.
However, you can hack it with HTML escape characters:
<head>
...
<meta property="og:description" content=" " />
...
</head>
Useful escape characters in this context;
- space
… - horizontal 3 dots (as #idomusha suggested, +1)
This is a solution:
<meta property="og:description" content="…" />
From the docs:
Basic Tags: These are the most basic meta tags that you should use for
all content types.
og:description is one of them, which is probably why you cannot set it to empty.
Using Dreamweaver CS6 Fluid Grid Layout.
I've researched the stackoverflow questions (and more) relating to this -
Facebook object debugger:
"Your page has meta tags in the body instead of the head. This may be because your HTML was malformed and they fell lower in the parse tree.
Please fix this in order for the tags to be usable."
Another answer on this site pointed out that something in the coding is resulting the secion ending before the meta tags - but I can't work out what it is. Code validator: there is a stray /head and body tag.
http://www.thatsrightratso.com.au/imp/lickit.html
What is it, can anyone help? Thank you
It looks like you added your meta tags inside of the body tag rather than the head. Typically the head section contains metadata and resources that are not directly displayed on the page, where these meta tags were added inside of the body, where HTML is rendered onto the page.
Take a look at this screenshot I took of your code. I have highlighted the Facebook meta tags for you. You should move these up inside of the head element.
<html>
<head>
<!-- title tags, stylesheets, other important items -->
<meta property="og:image" content="http://www.thatsrightratso.com.au/imagesimpjewellery/lickitring9ctyellowgold.jpg">
<meta property="og:description" content="Lickit ring, 9ct yellow gold or sterling silver, mens womens">
<meta property="og:url" content="http://www.thatsrightratso.com.au/imp/lickit/">
<meta property="og:title" content="Lickit">
</head>
<body>
<!-- Page Contents Rendered Here -->
</body>
</html>
For a Facebook share button, I deed to add some meta tags to a page in Liferay.
The result of the HTML should look like the following example:
<html>
<head>
<meta property="og:title" content="My website title" />
<meta property="fb:app_id" content="4711" />
</head>
<body>...</body>
</html>
How can I do that in Liferay WITHOUT coding but just by configuration in the admin control area?
Note: For www.mydomain.com/en the content of the meta tag should be in English. For www.mydomain.com/de it should be in German.
If this is not possible by configuration easily, it can be all in one single language.
You can add fb meta tags in portal_normal.vm in theme.
Also,these changes are not instantly reflected but takes a while until the fb crawlers re cache content from your tags.
I am using the play framework 1.2.6 and can't seem to find a handy way to set the meta data description in the html pages. To set the title there is this:
#{set title:'This is the title' /}
which generates
<title>This is the title</title>
Is there anything similar which would generate this:
<meta name="description" content="This is the description">
Actually, it was much easier than I thought. I just modified this part of code in header.html:
<meta name="description" content="#{get 'description' /}">
And then in a page that extends header.html:
#{set description:'This is the description' /}
I am trying to make a Facebook share button on my site. Everything goes well except Facebook garbles non-ascii symbols obtained from meta tags. For example:
I am sharing a page with URL http://example.com/facebook/.
The page at http://example.com/facebook/ has the following meta tags inside its HTML:
<head>
...
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
...
<meta name="title" content="John Smith won £10000!" />
<meta name="description" content="Wanna be next John Smith?" />
<link rel="image_src" href="http://example.com/img/logo.jpg" />
...
</head>
The problem is that a pound (£) sign is shown as � symbol in Facebook share pop-in, that's not a desired behaviour.
I would be grateful for any thoughts.
I would recommend replacing the pound-sign with the equivalent entity, i.e. £ = £. You may also need to add a charset definition, e.g. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> In fact, you might be able to get away with just the meta tag -- just put it before the others.