Octopress SEO: Site Keywords and Description
By default, the keywords and description generated by Octopress for site are those of the first post. However, what I want is to set more suitable keywords and description for my site.
First, we and keywords and descriptions for site in _config.yml
:
description: #put your site description
keywords: #put the keywords
Then in source/_includes/head.html
, change:
{% capture description %}{% if page.description %}{{ page.description }}{% else %}{{ content | raw_content }}{% endif %}{% endcapture %}
<meta name="description" content="{{ description | strip_html | condense_spaces | truncate:150 }}">
{% if page.keywords %}<meta name="keywords" content="{{ page.keywords }}">{% endif %}
To:
{% capture description %}{% if page.url == "/index.html" %} {{ site.description }}{% elsif page.description %}{{ page.description }}{% else %}{{ content | raw_content }}{% endif %}{% endcapture %}
<meta name="description" content="{{ description | strip_html | condense_spaces | truncate:150 }}">
{% if page.url == "/index.html" %}<meta name="keywords" content="{{ site.keywords }}">
{% elsif page.keywords %}<meta name="keywords" content="{{ page.keywords }}">{% endif %}
This should play the trick.
You do know how much effort I put to get the snippets above to show correctly! Link 1 and Link 2 as references.