Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2009-02-18 09:39:01
- yojinbo
- New Member
- Registered: 2009-02-18
- Posts: 2
Static pages and meta data
I’m stumped on this one – if it’s a simple solution, I’d appreciate someone pointing me in the right direction as I haven’t been able to wrap head around it, nor have I come across anything in the forums dealing with this particular problem, at least from the way I’m approaching it.
I’m using Textpattern for a mostly static site. I had no problem creating the static pages thanks to the FAQ, but I’ve run into problems when dealing with getting the meta data to reflect the current page. For example:
I’ve got a form which loads the meta data into the head of the HTML which goes something like this:
<txp:if_individual_article>
<title><txp:custom_field name="meta_title" default='<txp:title />' /> | <txp:site_name /></title>
<meta name="description" content="<txp:custom_field name="meta_description" default="foo" />" />
<meta name="keywords" content="<txp:custom_field name="meta_keywords" default="bar" />" />
<txp:else />
<title><txp:site_slogan /> | <txp:site_name /></title>
<meta name="description" content="foo" />
<meta name="keywords" content="bar" />
</txp:if_individual_article>
This works fine for dynamic pages, but when loading a static page, the second code block is always (understandably) being called. Other than creating a different page template for each static page (which seems like a horribly inefficient way of approaching things), how can I work around this particular problem?
Offline
#2 2009-02-18 10:31:10
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Static pages and meta data
Off the top of my head:
<txp:if_individual_article>
<title><txp:custom_field name="meta_title" default='<txp:title />' /> | <txp:site_name /></title>
<meta name="description" content="<txp:custom_field name="meta_description" default="foo" />" />
<meta name="keywords" content="<txp:custom_field name="meta_keywords" default="bar" />" />
<txp:else />
<!-- names of your sections that are "static" pages -->
<txp:if_section name="about,contact">
<!-- create a form named section_meta for each static page,
e.g: about_meta, contact_meta -->
<txp:output_form name='<txp:section />_meta' />
<txp:else />
<title><txp:site_slogan /> | <txp:site_name /></title>
<meta name="description" content="foo" />
<meta name="keywords" content="bar" />
</txp:if_section>
</txp:if_individual_article>
example form: about_meta
<title>About | <txp:site_name /></title>
<meta name="description" content="foo" />
<meta name="keywords" content="bar" />
There have been a couple plugins in the past for this sort of thing, but all the ones I could find were quite old and I don’t know how well they work.
(Edit: corrected code)
Last edited by Mary (2009-02-18 22:46:11)
Offline
Re: Static pages and meta data
Just a minor correction:
<txp:output_form name='<txp:section />_meta' />
(single quotes instead of double quotes, so the tag-in-tag could be parsed)
And a recommended plug-in for all meta/SEO tasks is rah_metas
Offline
#4 2009-02-18 14:56:01
- yojinbo
- New Member
- Registered: 2009-02-18
- Posts: 2
Re: Static pages and meta data
Mary, maniqui – thank you both for your suggestions – I’ll go back to playing around with things. With a combination of Mary’s code and rah_metas, I think I’ll have a pretty good chance of solving my current issues.
Again, thanks for helping out a noob!
Offline
Pages: 1