1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to build dynamic meta tags

Discussion in 'XenForo Questions and Support' started by Ryan Kent, May 13, 2011.

  1. Ryan Kent

    Ryan Kent Well-Known Member

    In the PAGE_CONTAINER template I added the following line of code:

    <meta name="keywords" content="Tera, Tera online, Tera pvp, play Tera, Tera USA, Tera Europe, Tera wiki">
    Google WMT noticed this code is on many pages, and I presume they are discounting those tags, as they probably should.

    What I would like to do is build a dynamic tag based on the page nodes. Let's assume I had a forum that talked about cars. Category: New Cars, Forum: Chevrolet, Sub-forum: Corvette. The code should automatically determine how many levels deep in which a thread exists.

    How can I build a dynamic tag such that meta name = category_node, forum_node, sub-forum_node? The output should be meta name = New Cars, Chevrolet, Corvette.

    This system would be great in that it would accurately provide the proper meta tags. It would be good SEO for forum owners, and from Google's perspective as well.
    Digital Doctor and lalalatrululu like this.
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    It's not worth the trouble. Meta keywords aren't used by search engines anymore.

    Having said that, here is some ugly hackish code that you can use in PAGE_CONTAINER to build a comma-list of node names like you want:

    <xen:foreach loop="$navigation" value="$breadcrumb">{xen:raw $breadcrumb.value}, </xen:foreach>{xen:raw $title}
    You can stick it in the keywords like so:

    <meta name="keywords" content="<xen:foreach loop="$navigation" value="$breadcrumb">{xen:raw $breadcrumb.value}, </xen:foreach>{xen:raw $title}" />
    Oracle likes this.
  3. Ryan Kent

    Ryan Kent Well-Known Member

    Works absolutely perfect.

    The only disappointment is hearing they aren't used anymore. I am sure this learning will come in helpful elsewhere.
  4. Ryan Kent

    Ryan Kent Well-Known Member

    Jake, one additional question on the code you shared.

    It works great but it doesn't include the "Forums" tag as part of the breadcrumb. I like how it skips "Home" but would like it to include "Forums". Looking at the code I don't see an obvious way to bump it one level higher to include it.

    I realize that the SEO benefit is minimal but I ask for my own learning of XF coding as well.
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    "Forums" would always be the same. You can just slap it on the beginning, hard-coded.

    <meta name="keywords" content="Forums, <xen:foreach loop="$navigation" value="$breadcrumb">{xen:raw $breadcrumb.value}, </xen:foreach>{xen:raw $title}" />
  6. Ryan Kent

    Ryan Kent Well-Known Member

    Actually on my site Forums is not always the same. I use this code on my whole site, and it always starts 1 node after I want it to.

    On my Wiki pages it misses "Wiki", on Blog pages it misses "blog", etc.
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I feel dirty doing this.

    <meta name="keywords" content="{$selectedTab.title}, <xen:foreach loop="$navigation" value="$breadcrumb">{xen:raw $breadcrumb.value}, </xen:foreach>{xen:raw $title}" />
  8. Brett Peters

    Brett Peters Well-Known Member

    I found this interesting a while back

    Oracle likes this.
  9. Brogan

    Brogan XenForo Moderator Staff Member

    It has already been stated many times that Google no longer still uses meta keywords.

    People still want them though.
  10. Ryan Kent

    Ryan Kent Well-Known Member

    The last 10 seconds of the video says it all. "At least for Google, we don't use [meta keywords] even the least little bit".

    When I posted this thread, I did not know this information. When Jake replied the first time, I believed him 100%. I recognize Jake as an expert, I know he would never share bad information on such an important subject.

    Call it OCD but I really like to finish projects, and to do so the right way. I continued learning about the XF template syntax right up to the end. I will look for other places to use this information.

    Right now, I have an issue where my forum threads rank well, but my wiki pages do not. I need to figure out a way to get keywords into wiki pages as tags, and this system may help.

    Thanks Brogan, Brett and Jake for the information. It is all helpful.
  11. Brett Peters

    Brett Peters Well-Known Member

    Yes, Jake does some awesome work around here indeed.
    I am unsure if Brogans post was referring to me.. But I shared the video for its information and not to deter Oracle from his quest :)
  12. Ryan Kent

    Ryan Kent Well-Known Member

    I decided to take Anthony's advice and sign up @ SEOmoz. For those not familiar with SEOmoz, I would describe them as a high-end SEO educational group.

    They took the keyword meta tag suggestion a step further by sharing the opinion the tag should be removed. A recent analysis of my site offered the following feedback:
  13. Ryan Kent

    Ryan Kent Well-Known Member

    I found a positive use for the dynamic meta-tag code --> dynamic meta description tags :)

    The wiki add-on Jaxel created currently uses the board description as the description on every wiki page. It's bad because Google recognizes that all the pages use the same meta description and I presume they ignore it.

    I have two options. I can emulate the process used on forum pages and grab the first ?75 characters of text. The problem is many pages begin with an image so just the attachment id shows. An alternative is to use the dynamic breadcrumb info.

    This code works in the PAGE_CONTAINER, but not in the add-on's template. I presume some variables are visible to the PAGE_CONTAINER template that are not visible everywhere? Is it simply a matter of including another template to access the values?

     <xen:container var="$head.description"><meta name="description" content="TERA, {$selectedTab.title}, <xen:foreach loop="$navigation" value="$breadcrumb">{xen:raw $breadcrumb.value}, </xen:foreach>{xen:raw $title}" /></xen:container>
    Digital Doctor likes this.
  14. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Is that XenCarta?

    I just installed that addon to test this. You can use this code in the EWRcarta_PageView template:

    <xen:container var="$head.description"><meta name="description" content="Wiki, <xen:foreach loop="$breadCrumbs" value="$breadcrumb">{xen:raw $breadcrumb.value}, </xen:foreach>{$page.page_name}" /></xen:container>
    XenCarta defines $breadCrumbs in the controller which you can use in a foreach.
  15. Ryan Kent

    Ryan Kent Well-Known Member

    Amazing, thank you.

    So if you can stand me for a few more questions, I am at a point where I desire to understand how things work.

    foreach loop="$navigation"....navigation represents what? a field in a table? a declared variable?

    and when you say $breadCrumbs is defined in the XenCarta controller, is that the requirement to access the information? A template can only access information which has been predefined in a controller?
  16. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    $navigation is an array containing the breadcrumb information. The foreach loop parses through the array.

    See this thread:

    Oracle likes this.
  17. FabioCesar

    FabioCesar Member

    I agree that the meta keywords no longer be used for positioning the first pages of google, but it helps a lot in research and especially in the google adsense.
    trantai likes this.
  18. Dinh Thanh

    Dinh Thanh Well-Known Member

    I also agree.
    The most important factors are content, title, link back and pagerank.
    Content is still the most important.

    We should use time to help people in my forum and make great contents for everyone.
    trantai likes this.

Share This Page