Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
How to remove the site name from appearing in the META Titles
I’m wondering if it is possible to remove the Site Name (which is handled in Admin Preferences) from automatically appearing in every Meta Title tag. I know that if I simply delete the name from Site Name that will happen, but then other non Meta items that depend on the Site Name is gone.
Any ideas?
Living the Location-Independent Life: www.NuNomad.com
Offline
Re: How to remove the site name from appearing in the META Titles
Simply change the HEAD section of your page template, or your meta form (if you’ve put these in a form) to not use txp:site_name
. If you’re using txp:page_title, that always includes the site name. You can simply replace it with a construction of your own making using <txp:site_name />
, <txp:title />
, <txp:section />
, & <txp:category />
with a few “if’s” and “else’s” , for example like Stuart has done.
TXP Builders – finely-crafted code, design and txp
Offline
Re: How to remove the site name from appearing in the META Titles
Hi Jakob!
Yes, that’s a good easy option. I’m wondering, however, if it is possible to add a custom field in Articles (under Advance Options). I was able to add a meta description field and Keywords field within Articles recently. Since I like to have specific wording in my Meta Titles (that may not be what I’m using for Sections or Article titles) it would be great to have such a feature.
Oh, and yes I’m using a form to handle my meta data.
Thanks for your thoughts.
Living the Location-Independent Life: www.NuNomad.com
Offline
Re: How to remove the site name from appearing in the META Titles
Yes, a custom field is no problem either but will obviously only work for articles (no custom fields in sections) so you need to use if_individual_article etc.
<title>
<txp:if_individual_article>
<txp:article><txp:custom_field name="seo_title" default="Standard title goes here" /></txp:article>
<txp:else />
<txp:section title="1" />
</txp:if_individual_article>
</title>
Change ‘seo_title’ to your custom field name in the example above and also the standard title (in case you have not defined your custom field) in the default attribute.
If you want a custom solution for the sections/categories you might want to try rah_output_section_form which allows you to define named forms for each section (or category) in which you can enter your seo title. You can define a standard form too to use in case you have not defined the respective forms. In the example below you would set up a standard form calledseo_standard_title
and any number of forms called seo_sectionname
(replacing ‘sectionname’ with your section name) for those sections where you want a custom seo title.
<title>
<txp:if_individual_article>
<txp:article><txp:custom_field name="seo_title" default="Standard title goes here" /></txp:article>
<txp:else />
<txp:rah_output_section_form prefix="seo_" default="seo_standard_title" />
</txp:if_individual_article>
</title>
Last edited by jakob (2010-05-09 10:17:12)
TXP Builders – finely-crafted code, design and txp
Offline
Re: How to remove the site name from appearing in the META Titles
Jakob,
Thank you! This looks good. (I’ll need the rest of this day to digest it though.)
Living the Location-Independent Life: www.NuNomad.com
Offline
Re: How to remove the site name from appearing in the META Titles
Well Jakob, I must be not understanding your directions. I created a custom field (through Admin Preferences) called meta_title. I then replaced the Title tag on my Form from: “<title><txp:title /></title>”
with:
<title>
<if_individual_article>
<txp:article><txp:custom_field name=“meta_title” default=“Health Services for the Homeless” /></txp:article>
<txp:else />
<txp:section title=“1” />
</if_individual_article>
</title>
When I go to view the page (view page source), the tile displays:
<title>
<if_individual_article>
Health Services for the HomelessHealth Services for the HomelessHealth Services for the Homeless
Last edited by laptophobo (2010-05-09 10:05:17)
Living the Location-Independent Life: www.NuNomad.com
Offline
Re: How to remove the site name from appearing in the META Titles
my mistake: it should read <txp:if_individual_article>
and </txp:if_individual_article>
(I forgot the txp: in front).
Last edited by jakob (2010-05-09 10:18:35)
TXP Builders – finely-crafted code, design and txp
Offline
Re: How to remove the site name from appearing in the META Titles
jakob wrote:
my mistake: it should read <txp:if_individual_article> and </txp:if_individual_article> (I forgot the txp: in front).
You don’t need the <txp:article />
tag either. On individual article page, article data is accessible without article tag. Like so:
<title>
<txp:if_individual_article>
<txp:custom_field name="seo_title" default="Standard title goes here" />
<txp:else />
<!--
Something else
-->
</txp:if_individual_article>
</title>
Last edited by Gocom (2010-05-09 19:26:23)
Offline
Re: How to remove the site name from appearing in the META Titles
Jakob, Gocom:
That solution works great! I’m able to have a unique Title for my Section, a unique Title as a default (in case my custom Article field is not filled out), and then the unique Title option within the custom field in my Article. The tag I went with looks like this:
<title> <txp:if_individual_article> <txp:custom_field name=“seo_title” default=“Health Services” /> <txp:else />Health Services</txp:if_individual_article>
</title>
Thanks for your help!
Last edited by laptophobo (2010-05-10 02:41:59)
Living the Location-Independent Life: www.NuNomad.com
Offline
Re: How to remove the site name from appearing in the META Titles
jakob wrote:
<title>
<txp:if_individual_article>
<txp:article><txp:custom_field name="seo_title" default="Standard title goes here" /></txp:article>
<txp:else />
<txp:rah_output_section_form prefix="seo_" default="seo_standard_title" />
</txp:if_individual_article>
</title>
I was blind, but now I see… That’s exactly what I was looking for!
Offline