SEO for Entries - Surge-ee/SurgeEO GitHub Wiki
SEO for entries (Using the SEO tab)
##Step 1: Add Data Adding SEO data to an entry is as simple as heading over to your Surgeeo Tab and entering in the relevant information.
There, that was easy.
##Step 2: Retrieving Data How do you get this wonderful, top of the SERPs SEO data into your templates? Here are two basic ways.
###1. By URL Title (Recommended) Here you have a template who's purpose is to show a blog post, article, or any single entry. In this example, we pretend to know that the URL Title of the entry is always in the third segment.
{embed="site/_header"
title="{exp:surgeeo:title url_title='{segment_3}'}"
keywords="{exp:surgeeo:keywords url_title='{segment_3}'}"
description="{exp:surgeeo:description url_title='{segment_3}'}"
}
<body>
<div class="container">
<div class="row">
{exp:channel:entries channel="some_channel"}
<article>
<h2>{title}</h2>
{content}
</article>
{/exp:channel:entries}
</div>
</div>
</body>
Note that we are using the {segment_3} variable for the url_title
parameter of our add-on tags. This tells SurgeEO to look at the third URL segment to find the URL Title corresponding to our SEO'ed entry.
###2. By Entry ID You can also grab the SEO data by the entries database ID. This is useful in cases where Entry ID is more appropriate or necessary versus the URL Title - For instance, when the URL Title is not present in the URL for that entry, or perhaps when using the Query module.
This example shows us wrapping the header embed inside of our channel entries loop (Only good for Single Entry pages!). This is so we have the entry_id
variable available to us. We recommend ensuring that this is set only once either by passing the entry_id upwards into the layout, or while forcing only one entry to be output with require_entry="yes"
.
{exp:channel:entries channel="some_channel" require_entry="yes"}
{embed="site/_header"
title="{exp:surgeeo:title entry_id='{entry_id}'}"
keywords="{exp:surgeeo:keywords entry_id='{entry_id}'}"
description="{exp:surgeeo:description entry_id='{entry_id}'}"
}
<body>
<div class="container">
<div class="row">
<article>
<h2>{title}</h2>
{content}
</article>
</div>
</div>
</body>
{/exp:channel:entries}
More examples can be found on our use-cases page.