Created
May 29, 2015 05:31
-
-
Save engram-design/be3fe032348f4461dd89 to your computer and use it in GitHub Desktop.
SEO for Craft
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends "_layout" %} | |
{% set seo = { | |
title: "My New Title" | |
} %} | |
{% block content %} | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% include "_includes/seo_meta" %} | |
<!doctype html> | |
<html lang="en"> | |
<head> | |
<!-- SE-Oh --> | |
{{ craft.sproutSeo.optimize() }} | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% set page = { | |
id: '', | |
title: '', | |
} %} | |
{% set desc = '' %} | |
{% if category is defined %} | |
{% set page = category %} | |
{% endif %} | |
{% if entry is defined %} | |
{% set page = entry %} | |
{% endif %} | |
{% if seo is not defined %} | |
{% set seo = {} %} | |
{% endif %} | |
{% set suffix = siteName %} | |
{% if page.articleBody is defined %} | |
{% if page.articleBody.type('text').first %} | |
{% set desc = page.articleBody.type('text').first.text|striptags|escape|slice(0, 160) %} | |
{% endif %} | |
{% endif %} | |
{% set seo = { | |
default: 'default', | |
id: page.id, | |
title: page.title ~ ' - ' ~ suffix, | |
description: desc, | |
canonical: craft.request.url, | |
ogTitle: page.title ~ ' - ' ~ suffix, | |
ogUrl: craft.request.url, | |
ogSiteName: siteName, | |
ogAuthor: siteName, | |
ogPublisher: siteName, | |
ogDescription: desc, | |
twitterSite: siteName, | |
twitterCreator: siteName, | |
twitterTitle: page.title ~ ' - ' ~ suffix, | |
twitterDescription: desc, | |
twitterUrl: craft.request.url, | |
} | merge(seo) %} | |
{% do craft.sproutSeo.meta(seo) %} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment