Copied to clipboard

Flag this post as spam?

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


  • Hansen24 2 posts 72 karma points
    Apr 20, 2018 @ 02:20
    Hansen24
    0

    Google Schema Markup/Microdata

    Hey!

    I am currently working on an Umbraco site. First time ever working with it.

    I am trying to implement Schema Markup/ Microdata.

    But I cant insert the following code in my header

    `

    <script type="application/ld+json">
    { 
        "@context" : "http://schema.org",
        "@type" : "Organization",
        "name" : "[organization name]",
        "logo" : "[logo image url]",
        "url" : "[website url]",
        "sameAs" : [
            "https://twitter.com/[username]",
            "https://www.facebook.com/[username]",
            "https://www.linkedin.com/company/[username]",
            "https://plus.google.com/[username]/posts"
        ]
    }
    

    `

    without getting an error. I am pretty sure its because Umbraco fetches the @ as something in the system. Since many things in Umbraco is called by "@".

    I found this thread: https://our.umbraco.org/forum/developers/razor/73608-using-google-schemas-creates-an-error-on-page

    But doing @@ makes the schema not getting the type of the schema markup.

    So how do I work around this? Also hard to insert microdata since everything is called by "@" something. Also using microdata I cant markup every specific thing also due to the @ call in the templates. Trying to it on this site.

    Sorry for any noob questions. As said, I am completely new to working with Umbraco.

  • Anders Bjerner 487 posts 2989 karma points MVP 7x admin c-trib
    Apr 20, 2018 @ 19:11
    Anders Bjerner
    0

    Hi,

    Adding an extra @ actually should escape your other @'s. I've tried copying your code, and inserting it in one of my own views. It works fine when I replace the two @ with @@.

    Can you share some more of your code - eg. the view in which you insert the script tag? Then I can try giving it a look ;)

    BTW - the use of @ is actually Razor, which is part of ASP.NET, which Umbraco then uses. Not that it necessarily matters, but may help if you need to search for solutions to an issue ;)

  • Hansen24 2 posts 72 karma points
    Apr 20, 2018 @ 21:18
    Hansen24
    0

    @Anders Bjerner

    Thank you for your reply!

    When testing the @@ as you mention - Google's testing tool cannot define which type of structured data it is. (Or at least I think it cant.)

    <script type="application/ld+json">
    { 
        "@@context" : "http://schema.org",
        "@@type" : "Organization",
        "name" : "[organization name]",
        "logo" : "https://hello.com/image",
        "url" : "https://test.com",
        "sameAs" : [
            "https://twitter.com/[username]",
            "https://www.facebook.com/[username]",
            "https://www.linkedin.com/company/[username]",
            "https://plus.google.com/[username]/posts"
        ]
    }
    

    Try yourself: https://search.google.com/structured-data/testing-tool/

    Not sure if Google will accept it since the @type comes out as "Unspecified Type".

    I am trying to insert it into SeoTags (Seo Checker extension) It looks like this right now.

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using SEOChecker;
    @{
        var meta = Model.Content.GetPropertyValue<SEOChecker.MVC.MetaData>("seoChecker");
    }
    <title>@meta.Title</title>
    <meta name="description" content="@meta.Description" />
    <meta name="robots" content="@meta.Robots" />
    <link rel="canonical" href="@Model.Content.UrlAbsolute()" />
    < -- Trying to insert script here -- >
    

    And thank you once again ;)

  • Nigel Wilson 944 posts 2076 karma points
    May 02, 2018 @ 00:53
    Nigel Wilson
    100

    Hi Hansen

    Are you simply using the testing tool and adding 2 '@' there, or are you copying / pasting the rendered html for your page ?

    I ask as Anders solution is the right way to get around the razor syntax, so whilst in code it looks wrong, the resulting html rendered to the page should be fine.

    Cheers, Nigel

Please Sign in or register to post replies

Write your reply to:

Draft