I created a basic test template and added both a header containing HTML in a snippet called footer and header each one.
Then I include this via tags on a template.
How can I have a different title and description for each template for seo purposes?
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
June 07, 2012 3:12pm
Subscribe [5]#1 / Jun 07, 2012 3:12pm
I created a basic test template and added both a header containing HTML in a snippet called footer and header each one.
Then I include this via tags on a template.
How can I have a different title and description for each template for seo purposes?
#2 / Jun 07, 2012 3:23pm
Hi Nibb,
I also put my doctype header in a snippet called {snip-doctype-header}. There are two ways to get a different title tag for each page the first involves having the closing head tag outside of the snippet.
Option 1:
{snip-doctype-header}
<title>unique title here</title>
</head>option 2:
{snip-doctype-header}Then inside the snip-doctype-header you would use the excellent, and free, Low Title plugin in conjunction with switch://ee.
Here is the relevant code I’m using on a current build.
{exp:switchee variable = "{segment_2}" parse="inward"}
{!--Listing page no extra title--}
{case value="#^P(\\\\d+)$#|''"}
{/case}
{!--Category name added here--}
{case value="category"}{exp:low_title:category url_title="{segment_3}"} |{/case}
{!--convert archive 2012/03 to March, 2012 for monthly archives--}
{!--
{case value="archives"}{exp:monthlee month="{segment_4}"}, {segment_3} |{/case}
--}
{!--single entry title added here--}
{case default="yes"}{exp:low_title:entry url_title="{segment_2}"} |{/case}
{/exp:switchee}Hope this helps.
I personally prefer this way to using embeds and passing variables through as you save on template processing overhead.
#3 / Jun 07, 2012 3:33pm
Im not that advanced yet, im a beginner on EE and I find it extremely hard to just to do something as simple as to replicate how my site works now.
My page is basically composed of a header and footer each one included via PHP include. On the title and meta description of the header, I again include via PHP the custom descriptions. This sounds simple?
Well I cannot find how to do something this simple with EE.
I paste the whole header HTML code in the snippet, including CSS, javascript, etc. In the future I think I may be better putting this on each own template but the idea is to break up the site with time and start rolling EE as fast as possible.
I did not create channels because im the only one editing.
The reason I purchased EE was so I could log in and have all the Titles, and Meta Descriptions for pages listed so I can edit them manually when I want without touching each page manually and to be able to clone a template as fast as possible and then put content on it.
Honestly I did not understand what your posts said. Why would you put the doctype header in its own snippet? I mean how offend would someone actually change their website declaration? I never did in years.
#4 / Jun 07, 2012 6:41pm
Try splitting things up into several snippets so your template looks something like this. along the lines of what Sean said:
{sn_html_start}
{exp:channel entries channel="channelname" limit="1"}
<title>{title}</title>
{/exp:channel:entries}
{sn_head_body}
<article>
{exp:channel entries channel="channelname" limit="1"}
<header>
<h1>{title}</h1>
</header>
{your_channel_custom_field_x}
{your_channel_custom_field_y}
{/exp:channel:entries}
</article>
{sn_html_end}.. each snippet (sn_xxx} contains whatever code you want, eg {sn_html_start} might contain
<!doctype html>
<html>
<head>#5 / Jun 07, 2012 6:52pm
Thanks, after thinking about it I actually took the header and footer and put them on their own templates, I think snippets are more appropriate for smaller HTML codes, even when snippets work as well. I guess there are multiple ways to do the same things. Can snippets include other snippets just like you can with templates?
The part I was stuck was how to get the titles, meta tags into each template one in a customized way.
It seems you are doing this via channel and I found some blogs with the same example, also using channel, I have to admin I did not even explored the channel features yet because I don´t plan others to publish data on the site but I guess I may still need to do this via channel for my own proper organization. I guess this is the way then, the title, meta tags need to be pulled out via channels.
Im just wondering how this will look if you have hundreds of pages, would that not be a huge channel list to manage?
I also prefer not use plugins for now as im new to EE and I want to learn how to do basic stuff with it first before expanding it.
#6 / Jun 07, 2012 7:31pm
Thanks, after thinking about it I actually took the header and footer and put them on their own templates, I think snippets are more appropriate for smaller HTML codes, even when snippets work as well. I guess there are multiple ways to do the same things. Can snippets include other snippets just like you can with templates?
I think you can embed snippets in snippets, but that might give you a small performance hit. Much better to divide into logical chunks.
The part I was stuck was how to get the titles, meta tags into each template one in a customized way.
That’s just one method, you can use an embedded template, though too many embedded templates can result in a performance hit (more database queries). There are probably a few other methods as well - the key thing here is to experiment to see what works for you, rads a few tutorials and these forums as there are plenty of approcahes you can take.
It seems you are doing this via channel and I found some blogs with the same example, also using channel, I have to admin I did not even explored the channel features yet because I don´t plan others to publish data on the site but I guess I may still need to do this via channel for my own proper organization. I guess this is the way then, the title, meta tags need to be pulled out via channels.
Your can use as many Channel entries tags as you want in one template so my example just demonstrates using the same tag but for different purposes.
Im just wondering how this will look if you have hundreds of pages, would that not be a huge channel list to manage?
You don’t need one template for each page, if you’re managing something like artickles you probably only need 2 templates, one for a listing/category view and the other for the full article.
I also prefer not use plugins for now as im new to EE and I want to learn how to do basic stuff with it first before expanding it.
That’s a good way to start, EE is very powerful once you’ve got familiar with it, and when you get the “lightbulb” moment you’ll hopefully see a million possibilities! You only need reach for addons when there’s no way to do something using EE inbuilt tools.
#7 / Jun 07, 2012 7:44pm
Thanks again for the reply.
Yes, im reading as much as I can and I advanced allot.
Im playing with channels and its like you mentioned. Its more build for articles, news, blogs, etc. My page content, the ones I want to build into EE are mostly commercial pages that promote a product so each content is completely different to the next page (besides header and footer which is the same on all)
I created a SEO channel and I was able to insert it just fine using Title, Descriptions and Keywords.
What I cannot seems to find is how to make this structure make sense.
Let me explain it.
My header and footer are templates in a group “site”
So now lets say I have a template called “product”, this page has included the “header” and “footer”.
Now it seems I can publish its SEO data just fine, and pull it via for example “seo” channel.
But since “products” page does not actually have its own SEO code, its including from header template, and this one from the channel I would end up exactly with the same problem of having to manually edit each template to pull the SEO data each one from its own SEO channel.
I was rather thinking a way I can just duplicate the templates, and each template will tell the header dynamically which channel it will use for its SEO.
This way I can just publish the SEO content for each page without having to actually manually change the channel name on each one. Not sure if that makes sense.
#8 / Jun 07, 2012 8:37pm
Ok so you have “site” as your main template group?
In your product template you can embed your header and footer templates by using the embed tag:
{embed="site/header"}
{embed="site/footer"}You could also add Page title, meta keyowrds fields as custom channel fields.
Have you checked out Boinks tutorials at http://www.train-ee.com/courseware/free-tutorials ? Well worth trying those out to grasp some basics.
#9 / Jun 07, 2012 8:42pm
Yes that is how I embed the header and footer. I also have some global variables and snippets. Everything works so far. I just need to think a bit better the logic and structure behind generating on the fly the names for the channels so I don´t have to the channel name manually on each new template I create. The idea of having this is not to have duplicates, so each page needs to have its own title, description, etc.
I think I already read some tuts on that link but I will try again.
#10 / Jun 08, 2012 4:23pm
Hey guys!
This is awesome. Love the exchange here.
I am going to move this over to the Community Help Forum so the discussion can continue!
Cheers,
#11 / Jun 12, 2012 8:25am
I just need to think a bit better the logic and structure behind generating on the fly the names for the channels so I don´t have to the channel name manually on each new template I create.
When you create a channel, you are at that time offered the option of creating a template group for it. And in your template, if you have pre_parse variables such as “my_channel” and “my_template_group” EE automatically updates those lines, knowing that you are creating the template group in concert with the creation of the new channel. So then both happen at the same time - just one potential time saver for you.
#12 / Jun 12, 2012 3:10pm
Ok that tip is new. What are this pre variables that will be updated when creating a new group from a channel?
This seems like a time saver as you would create the template right from the channel creation.