Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • René Andersen 238 posts 684 karma points
    Mar 17, 2015 @ 10:59
    René Andersen
    0

    Special characters in meta and alt text

    Hi

    I have a problem when using special characters in meta and alt text.

    Meta description and Alt text like this: Test test æøå

    Generates this output:

    <meta name="description" content="Test test &#230;&#248;&#229;">

    <img src="#" alt="Test test &#230;&#248;&#229;" />

    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:

    <meta name="description" content="@Umbraco.Field("pageDescription")">
    <title>@Umbraco.Field("pageTitle")</title>

    Does anybody know whats wrong?

    // René

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Mar 17, 2015 @ 11:13
    Dennis Aaen
    0

    Hi René

    Perhaps you should set this meta tag in to your master template in the head section, to ensure that it uses UTF-8 encoding.

    <meta http-equiv="content-type" content="text/html; charset=utf-8" />

    Hope this helps,

    /Dennis

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 17, 2015 @ 11:16
    Jan Skovgaard
    0

    Hi René

    Are you using UTF-8 when saving your files? I have noticed that sometimes you need to save the files as UTF-8 with BOM for some reason.

    If you're using Visual Studio or Sublime Text you can use the "Save with encoding" option to see if it works.

    Otherwise using <meta charset="UTF-8"> should be enough.

    /Jan

  • René Andersen 238 posts 684 karma points
    Mar 17, 2015 @ 12:07
    René Andersen
    0

    Hi Dennis and Jan

    It is set to utf-8 and tried to add the line of code that Dennis posted but nothing changed.

    I am using Visual Studio and I have saved it with encoding "Unicode (UTF-8 with signature) - Codepage 65001 - But no change after this.

    Is this the same as with BOM, because I cant find the option "With BOM".

    It is strange that it is only Alt text and Meta description that have problems with special characters. Does it have something to do with how it is stored in the database?

    Is it wrong to use special character in Meta and Alt descriptions?

    If I directly insert æøå in the HTML, then it shows æøå without any problems.

    I have testet the Fanoe starter kit and the problem is also appearing here.

    I have also tried to:

    <p>@Umbraco.Field("pageDescription")</p>

    And then it shows the "æøå" correctly.

    // René

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 17, 2015 @ 12:31
    Jan Skovgaard
    0

    Hi René

    Can't remember how to save with or without BOM using VS. It may be called something different.

    But I was thinking of the issue where ÆØÅ characters are messed up when rendering on the page. I have seen this issue before as well but can't currently remember how to fix it.

    Does it also happen if you try to create a partial view macro for rendering the fields?

    /Jan

  • René Andersen 238 posts 684 karma points
    Mar 17, 2015 @ 15:19
    René Andersen
    0

    Hej Jan

    I have tried to make a partial view, but still the same problem. But you asked me to try with a partial view macro and i don't know how to do that. :-(

    On earlier webpages I have used this code without any problems. I am aware that it can´t be used anymore.

    <meta name="description" content="<umbraco:Item field='metaDescription' runat='server' />" />

    I found this topic which descripes excatly the same problem:

    https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/56401-Textbox-multiple-encoding

    // René

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 17, 2015 @ 15:33
    Jan Skovgaard
    0

    Hi René

    Ok, if you already tried making a partial then nevermind - Using a partial view macro will end up with the same result I think. I'll try to see if I can flick something together in order to test this...something in the back of my mind tells me I've seen it before.

    I'll get back to you.

    /Jan

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 17, 2015 @ 15:57
    Jan Skovgaard
    100

    Hi René

    Ok, just did some testing of my own.

    Seems that no matter where my text is coming from (rich text editor, textfield, textstring) then all special characters like danish æ,ø,å and apostrophes will be entity encoded for some reason.

    I'm not sure it's an Umbraco specific thing though since I just tested on a Sitecore solution I have been working on where I see the same issue. So I suspect it might be related to .net / mvc somehow. I also checked an older site of mine, which is running Umbraco 4.7 (and therefore based on webforms) and here the special characters are not being entity encoded.

    Even though it seems a bit annoying it should not be a serious issue though since Google and other search engines will still be able to display the entities correctly as long as they're being properly encoded.

    I'm confident that our Sitecore client and our marketing department would have made som serious noise if the entities influenced how search results looked in SERP because of the entity encoding :D - So I don't think you should worry too much about it.

    But if you feel like it you can always try and file an issue at the issue tracker

    Hope this helps.

    /Jan

  • René Andersen 238 posts 684 karma points
    Mar 17, 2015 @ 16:14
    René Andersen
    0

    Hi Jan

    Thank you for looking into this problem. With your description I am convinced that it is not a problem especially the part "Google and other search engines will still be able to display the entities correctly".

    I have only been testing looking at the source code through the browser.

    Thanks once again!

    // René

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 17, 2015 @ 16:44
    Jan Skovgaard
    1

    Hi René

    As usual you're very welcome :) It got my curious since it used to be displayed correctly and could potentially be a serious issue - But as we found out it's not :)

    Happy coding mate!

    /Jan

  • René Andersen 238 posts 684 karma points
    Mar 18, 2015 @ 23:28
    René Andersen
    0

    Hi Jan

    Just a little update on this subject. Before you posted your answer I asked the same question on stackoverflow and got an answer from sebastiaan. He actually posted a (ugly) solution but at the same time he confirmed your answer.

    See: http://stackoverflow.com/questions/29101236/meta-description-with-special-characters-in-umbraco/29105081?noredirect=1#comment46483433_29105081

    // René

Please Sign in or register to post replies

Write your reply to:

Draft