Copied to clipboard

Flag this post as spam?

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


  • Laurence Gillian 600 posts 1219 karma points
    Jun 25, 2014 @ 17:39
    Laurence Gillian
    0

    Meta Tags -> OpenGraph and Twitter Errors

    Hej!

    I'm updating an XSLT, that spits out meta tags for a website. I'd like to add the new Twitter Cards and OpenGraph tags into this, as it's a nice idea :-) The problem is, I get a parsing error whenever I try and save.

    I'd hoped, it would be a simple case of adding the correct name spaces, but sadly not!

    Any ideas? Surely someones done this before :-)

    Laurence

     <?xml version="1.0" encoding="UTF-8"?>
     <xsl:stylesheet
       version="1.0"
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
       xmlns:umb="urn:umbraco.library"
    
       exclude-result-prefixes="umb"
     >
    
       <xsl:output method="xml" omit-xml-declaration="yes"/>
       <xsl:param name="currentPage"/>
    
     <!-- Meta, Laurie 5th September 2011 -->
    
    <xsl:template match="/">
    <!-- Title -->
    <!-- normal meta removed -->
    
    <meta property="og:title" content="{($currentPage/contentHeader | $currentPage/@nodeName[not(normalize-space($currentPage/contentHeader))])[1]}"/>
    <meta property="og:type" content="article"/>
    <meta property="og:url" content="{umb:NiceUrl($currentPage/@id)}"/>
    
    <meta property="og:description" content="{$currentpage/metaDescription}"/>
    <meta property="article:author" content="http://url/"/>
    
    <meta name="twitter:site" content="@uniquelau"/>
    <meta name="twitter:title" content="{($currentPage/contentHeader | $currentPage/@nodeName[not(normalize-space($currentPage/contentHeader))])[1]}"/> 
    
    <xsl:choose>
        <xsl:when test="$currentPage/contentImage != ''">
            <meta name="twitter:card" content="photo" />
            <meta name="twitter:image:src" content="{umb:GetMedia($currentPage/propertyAlias, 0)/umbracoFile}" />
            <meta property="og:image" content="{umb:GetMedia($currentPage/propertyAlias, 0)/umbracoFile}" />
        </xsl:when>
        <xsl:otherwise>
            <meta name="twitter:card" value="summary" />
        </xsl:otherwise>
    </xsl:choose>
    

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jun 25, 2014 @ 17:50
    Jan Skovgaard
    0

    Hi Laurence

    What does the error message say if you add the ?umbdebugshowtrace=1 querystring or look in the /app_data/logs file, depending on the version of Umbraco you're running?

    At a first glance the above looks allright to me.

    /Jan

  • Laurence Gillian 600 posts 1219 karma points
    Jun 25, 2014 @ 17:56
    Laurence Gillian
    0

    Hey Jan! The parsing error from the XSLT processor in Umbraco is:

    System.Xml.Xsl.XslLoadException: Top-level element 'meta' may not have a null namespace URI. An error occurred at (36,3).

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Jun 25, 2014 @ 18:00
    Chriztian Steinmeier
    0

    Hey Laurence,

    That error strikes me as weird - can you post the complete XSLT as a Gist maybe? It's very likely a namespace error - but it sounds like there's a misplaced meta element somewhere...

    /Chriztian

  • Laurence Gillian 600 posts 1219 karma points
    Jun 25, 2014 @ 18:18
  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Jun 25, 2014 @ 19:02
    Chriztian Steinmeier
    1

    Ah - thought so :)

    You're meta tags section is placed directly as children of the xsl:stylesheet tag - you must put them inside a template.

    And I know you know that :)

    /Chriztian

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jun 25, 2014 @ 19:08
    Jan Skovgaard
    0

    Doh! Of course...one can be so blind sometimes :D

    /Jan

  • Laurence Gillian 600 posts 1219 karma points
    Jun 25, 2014 @ 19:17
    Laurence Gillian
    0

    Gah! >.< That had me stumped! I love the internet! I could of been stuck on that for days, months, years even! ;-)

Please Sign in or register to post replies

Write your reply to:

Draft