0 users online. Create an account or sign in to join them.Users

Search

For a big website I’m making now, the clients want to manage the title, description and keywords of every single page of the website. That means for as well all the main pages as page entries. They want input fields for this when e.g. they create a new entry. So this is probably something were the extension ‘SEO Manager’ doesn’t help anymore.

How should I handle this request?

Thanks

We create a SEO section here at work, that has Meta Title, Meta Description (Textbox), Meta Keywords (Enhanced Tag List) and Path (Expression field).

The path just refers to the URL, such as /dogs-and-cats/.

A global datasource filters on $current-path for each page it’s attached to

Yeah, that’s basically what buzzomatic’s SEO Manager does right? But is your way of doing it also apply able for every entry page there is? Like I have a resorts page with allot of items displayed on it, and the entry pages of these items should have their own unique meta data…

Like I have a resorts page with allot of items displayed on it, and the entry pages of these items should have their own unique meta data…

You could create an entry in the metadata section for each entry in the resorts section, or you could mix/append data from a single resort entry (e.g. tags) to existing metadata (e.g. from a general rule with something like /resorts/*) in the expression field.

Why don’t you just add extra fields to your entry section for the keywords and use Publish Tabs for the interface?

Thanks I will try it out

For master pages, it’s still a toss up between the Pages Field extension, which I use in a section with a title field, description and keywords, or the Page Fields extension which lets you add fields to pages.

For detail pages, I just add the fields in like Nils said.

I still can’t decide which is better for the master pages though.

But is your way of doing it also apply able for every entry page there is?

Correct, because the expression is just a regex on the URL, so if you want to give /articles/read/dogs-are-better-than-cats/ some specific SEO, while setting other SEO for all other articles, /articles/read/*/.

Nils and designermonkey’s solutions work too, but we’ve just found ours to suit our situation better.

What I have done is created a new SEO section for the master pages, and created SEO fields in the entry creators for each individual entry. This works fine. It takes some time to do it for all my sections because I have allot. But Thanks! It works great.

This seems like hard work to me. What is required IMO is that, when you create a new page, you should be able to add page specific content to the head section as well as the data section. The way I have gone about this is, in your page.xsl file, import your master style-sheet (I have one for HTML5 and one for Strict DOCTYPES:

<xsl:import href="../utilities/html5.xsl" />

Below this, add a new template for your page specific head content:

<!-- page specific head section content here -->
<xsl:template name="head">

<meta name="Description" content="description here" />
<meta name="Keywords" content="key,words,here" />
<!-- page style-sheet here -->
<link type="text/css" href="{path}page.css" />
<!-- plus any other page specific head stuff -->

</xsl:template>

<!-- page content here -->
<xsl:template match="data">
  ..
</xsl:template>

In your master style-sheet, call this new template:

...

<head>
 <meta name="title" content="{$page-title}" />
 <meta name="tags" content="" />
 <title><xsl:value-of select="$page-title"/> | <xsl:value-of select="$website-name"/></title>

 <xsl:call-template name="head"/>

 <!-- Fav Icons -->
 <link rel="shortcut icon" href="/favicon.ico?" type="image/x-icon" />
 <link rel="icon" type="images/png" href="/favicon.png" />

 <!-- Plus other global head section stuff -->
</head>

...

If you create a template file for page.xsl, this will give you a quick start every time you add a new page.

Stay DRY.

I decided to do very similar, using a master template calling

<xsl:apply-templates mode="head" />

and changing the mode dependent on what templates from my page specific xsl I want. Therefore the same can be used for content, sidebars, visual headers and footers, the sky’s the limit!

This way, you’re not calling a template, and it stays relevant to the node level it’s called from.

Do you then just add the mode=”head” attribute to the page ‘head’ template?

It isn’t really a head template, more like this

<xsl:template match="data" mode="head">
    ....
</xsl:template>

Then you can crawl through your nodes to find the right ones.

I bet Allen can find a better way though…

Thanks @designermonkey, I tested that and it works fine.

This also works: In your master, link to a static XHTML fragment that has html as a root element. Let’s say you want to populate the footer that is shared by another framework in your site:

<xsl:variable name="footer" 
  select="document(concat($site-root,'h/footer.xml'))" />

Then, still in your master, at the point you wish to include the footer:

<xsl:apply-templates select="$footer/html/*" />

Which uses an identity template to copy all nodes at the above location:

<xsl:template match="*">
 <xsl:element name="{name()}">
  <xsl:apply-templates select="@*|node()"/>
 </xsl:element>
</xsl:template>

  <xsl:template match="@*|text()|comment()|processing-instruction()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

I’ve used this technique for years (very DRY) but I have a feeling you Symphony folk will show me a better way.

@Nils how did you perform add extra fields to your entry section for the keywords

?

i call from News page metatag template:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:template name="metadata">
<xsl:choose>
    <xsl:when test="$entry = ''">
        <meta name="description" content="whole section description " />
        <meta name="keywords" content="whole section keywords" />
    </xsl:when>
    <xsl:otherwise>
        <xsl:call-template name="new_metatags"/>
    </xsl:otherwise>
</xsl:choose>

</xsl:template>

<xsl:template match="data">
...

in my get-new.xsl utility i add this:

<xsl:template name="new_metatags">
            <meta name="keywords">
                <xsl:attribute name="content">
                    <xsl:apply-templates select="title"/>
                </xsl:attribute>
            </meta>
            <meta name="description" content="description here" />
</xsl:template>

but in source code keywords is empty

<meta name="keywords" content="" />

what could be wrong?

your value-of has no context, so it's trying to pull the xml node /title where you probably actually want /data/my-funky-datasource/entry/title.

on a side note, you can save yourself some typing by calling xpath inside of your html attributes with curly braces:

<meta name="description" content="{/data/my_funky_datasource/entry/title}" />

thank you fawx

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details