Skip to content

Instantly share code, notes, and snippets.

Created June 25, 2014 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/c31297d8b91d4bdd9c79 to your computer and use it in GitHub Desktop.
Save anonymous/c31297d8b91d4bdd9c79 to your computer and use it in GitHub Desktop.
Meta Tags, with Open Graph and Facebook, Umbraco, XSLT
<?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 -->
<!-- <xsl:value-of select="($currentPage/metaTitle | $currentPage/@nodeName[not(normalize-space($currentPage/metaTitle))])[1]" /> -->
<xsl:if test="($currentPage/metaKeywords | $currentPage/ancestor-or-self::publicHome/metaKeywords[not(normalize-space($currentPage/metaKeywords))])[1] !=''">
<meta name="keywords" content="{($currentPage/metaKeywords | $currentPage/ancestor-or-self::publicHome/metaKeywords[not(normalize-space($currentPage/metaKeywords))])[1]}" />
</xsl:if>
<xsl:if test="$currentPage/metaDescription !=''">
<meta name="description" content="{$currentPage/metaDescription}" />
</xsl:if>
<!-- If Russian, include Russian fonts -->
<xsl:if test="$currentPage/ancestor-or-self::Home/@id = '1425'">
<link href="http://fonts.googleapis.com/css?family=PT+Sans:700&amp;subset=cyrillic" rel="stylesheet" type="text/css" />
</xsl:if>
<xsl:if test="$currentPage/contentPublicationURL != ''">
<link rel="canonical" href="{$currentPage/contentPublicationURL}"/>
</xsl:if>
</xsl:template>
<!-- OpenGraph Social -->
<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=""/>
<meta name="twitter:site" content=""/>
<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>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment