Forum

Thread tagged as: Meta, Blog

BLOG SEO TEMPLATES

So this is what i want to make editable on each blog posting

<perch:if exists="title"> <title> <perch:content id="title" type="text" label="title" suppress="true" /></title> </perch:if>
<perch:if exists="description"> <meta name="description" content="<perch:content id="description" type="textarea" suppress="true" label="Page Description" help="This will show in search engine results and should be up to 160 characters max" />"/> </perch:if>
<perch:if exists="keywords"> <meta name="keywords" content="<perch:content id="keywords" type="textarea" suppress="true"label="Keywords" help="Words and phrases separated with comma" />"/> </perch:if>
<perch:if exists="author"> <meta name="author" content="<perch:content id="author" type="text" suppress="true" label="Author" />"/> </perch:if>
<perch:if exists="no-robots"> <perch:content id="no-robots" type="checkbox" label="Robots : Don't include Robot Meta" help="Check this box if you do not wish to include robot meta, otherwise select from the list below" suppress="true"/>
<perch:else /> <meta name="robots" content="<perch:content id="robots1" type="checkbox" label="All" value="all," /><perch:content id="robots2" type="checkbox" label="None" value="none," /><perch:content id="robots3" type="checkbox" label="Index" value="index," /><perch:content id="robots4" type="checkbox" label="No index" value="no index," /><perch:content id="robots5" type="checkbox" label="Follow" value="follow," /><perch:content id="robots6" type="checkbox" label="No follow" value="nofollow," /><perch:content id="robots7" type="checkbox" label="No image index" value="noimageindex," /><perch:content id="robots8" type="checkbox" label="No image click" value="noimageclick," />" /> </perch:if>

I know to add the fields to your post.html template with suppress="true" set so they're not output, But i'm a bit lost from there on in.

I have been give this information from drew but i just need a little more direction. An yone able to help?

Copy them into a template to output into the <head> of your page without the suppress attributes. Use perch_blog_custom() to output the post in the head of the page using the head template.

Chris James

Chris James 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

  1. Save that as a new template, e.g. templates/blog/seo.html
  2. Remove the suppress="true" attributes from the new template. Delete any instance of suppress="true"
  3. In the head of you post detail page:
<?php
    perch_blog_custom(array(
        'filter'=>'postSlug',
        'match'=>'eq',
        'value'=>perch_get('s'),
        'template'=>'seo.html',
    ));
?>

Hi Drew

Thanks for this i have done what you have said to do but it still wont work. :(

Here is the post.html section:

<perch:if exists="title"> 
<title> <perch:content id="title" type="text" label="title" suppress="true" />
</title> 
</perch:if>

<perch:if exists="description"> 
<meta name="description"  suppress="true" content="<perch:content id="description" type="textarea" label="Page Description" help="This will show in search engine results and should be up to 160 characters max" />"/> 
</perch:if>

<perch:if exists="keywords"> 
<meta name="keywords"  suppress="true"  content="<perch:content id="keywords" type="textarea" label="Keywords" help="Words and phrases separated with comma" />"/> 
</perch:if>

<perch:if exists="author"> 
<meta name="author"  suppress="true"  content="<perch:content id="author" type="text" label="Author" />"/> 
</perch:if>

<perch:if exists="no-robots"> 
<perch:content id="no-robots" type="checkbox" label="Robots : Don't include Robot Meta" help="Check this box if you do not wish to include robot meta, otherwise select from the list below" suppress="true"/>

<perch:else /> <meta name="robots" content="<perch:content id="robots1" type="checkbox" label="All" value="all," /><perch:content id="robots2" type="checkbox" label="None" value="none," /><perch:content id="robots3" type="checkbox" label="Index" value="index," /><perch:content id="robots4" type="checkbox" label="No index" value="no index," /><perch:content id="robots5" type="checkbox" label="Follow" value="follow," /><perch:content id="robots6" type="checkbox" label="No follow" value="nofollow," /><perch:content id="robots7" type="checkbox" label="No image index" value="noimageindex," /><perch:content id="robots8" type="checkbox" label="No image click" value="noimageclick," />" /> </perch:if>

here is the post.php section:

<?php
    perch_blog_custom(array(
        'filter'=>'postSlug',
        'match'=>'eq',
        'value'=>perch_get('s'),
        'template'=>'seo.html',
    ));
?>

and here is the seo.html

<perch:if exists="title"> <title> <perch:content id="title" type="text" label="title" /></title> </perch:if>
<perch:if exists="description"> <meta name="description" content="<perch:content id="description" type="textarea" label="Page Description" help="This will show in search engine results and should be up to 160 characters max" />"/> </perch:if>
<perch:if exists="keywords"> <meta name="keywords" content="<perch:content id="keywords" type="textarea" label="Keywords" help="Words and phrases separated with comma" />"/> </perch:if>
<perch:if exists="author"> <meta name="author" content="<perch:content id="author" type="text" label="Author" />"/> </perch:if>
<perch:if exists="no-robots"> <perch:content id="no-robots" type="checkbox" label="Robots : Don't include Robot Meta" help="Check this box if you do not wish to include robot meta, otherwise select from the list below"/>
<perch:else /> <meta name="robots" content="<perch:content id="robots1" type="checkbox" label="All" value="all," /><perch:content id="robots2" type="checkbox" label="None" value="none," /><perch:content id="robots3" type="checkbox" label="Index" value="index," /><perch:content id="robots4" type="checkbox" label="No index" value="no index," /><perch:content id="robots5" type="checkbox" label="Follow" value="follow," /><perch:content id="robots6" type="checkbox" label="No follow" value="nofollow," /><perch:content id="robots7" type="checkbox" label="No image index" value="noimageindex," /><perch:content id="robots8" type="checkbox" label="No image click" value="noimageclick," />" /> </perch:if>

Can you see where its not working?

Drew McLellan

Drew McLellan 2638 points
Perch Support

What's not working about it?

Its not allowing me to edit the SEO tags that I have made editable via the perch cms for any posts that i create.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

What does "not allowing" mean? Do they appear but are somehow uneditable? Are they displaying in the markup? We don't know what the actual issue you are having is so it's really hard to help.

I can immediately see you have an invalid id attribute (you can't have a - in an id so no-robots needs to become no_robots or some such thing).

Hi Rachel

I have no doubt that its me thats the bug and not anything to do with Perch. When I say its not allowing me to do so I mean It doesn't show up in the backend of the cms so I cant add tags to the pages seo.

I have set up the seo for regular pages of the site and I can add meta tags to that page via perch, but i can't seem to do so with blog posts.

I really appreciate your help and I can understand it must be frustrating dealing with me. Sorry :)

Drew McLellan

Drew McLellan 2638 points
Perch Support

This is a Blog template, but you've used <perch:content /> tags. Swap those to <perch:blog />. The tags need to match the app you want to process them.

Ah yes of course. Ok I will try that now.

This is brilliant thank you guys. Your product never ceases to amaze me and I 'm greatful for the time taken to help me out with this problem,( all of my own doing of course).