ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Dynamic Page Titles - Best practice?

August 27, 2011 10:06am

Subscribe [5]
  • #1 / Aug 27, 2011 10:06am

    Osze

    42 posts

    Hi,

    What is the best practice for dynamic page titles?

    My current solution:

    Page Template:

    {embed="embeds/.html_top"}
    
    {!-- START MX JUMPER #TITLE #DESCRIPTION --}
    {exp:mx_jumper:put name="page_title"}My website title{/exp:mx_jumper:put}
    {exp:mx_jumper:put name="page_description"}My website description{/exp:mx_jumper:put}
    {!-- END MX JUMPER #TITLE #DESCRIPTION --}


    In my Embeds/.html_top template

    <title>{exp:mx_jumper:out name="page_title"}</title>
    <meta name="description" content="{exp:mx_jumper:out name="page_description"}" />

    I’ve used MX Jumper instead of {embed="embeds/.html_top" page_title="" page_description=""} to get ride of the {channel}-tag that is needed when it becomes dynamic page titles.

    With MX jumper I can put in the variables into an already existing {channel}:

    {exp:channel:entries channel="extra" sort="asc" disable="categories|member_data|pagination|trackbacks" dynamic="no" url_title="{segment_2}"} 
    {!-- START MX JUMPER #TITLE #DESCRIPTION --}
    {exp:mx_jumper:put name="page_title"}{seo_page_title} | {site_name}{/exp:mx_jumper:put}
    {exp:mx_jumper:put name="page_description"}{seo_page_description}{/exp:mx_jumper:put}
    {!-- END MX JUMPER #TITLE #DESCRIPTION --}

    My dream solution would be that instead of a template (embeds/.html_top) I could use a Snippet and use MX jumper but because of the parsing order this is not possible.

    What is the best practice for dynamic page titles?

  • #2 / Aug 28, 2011 6:50pm

    Dan Decker

    7338 posts

    Osze,

    In my opinion, the best practice is whatever gets the results you are looking for. I’m going to send this over into Community Help to keep the discussion going. Feel free to start a new thread if you ever need assistance with a technical issue.

    Cheers!

  • #3 / Aug 28, 2011 7:33pm

    Osze

    42 posts

    In my opinion that was not the answer I was hoping for but maybe my question was badly written.

    How are the most experienced EE developers building dynamic page titles to minimize DB queries?

  • #4 / Sep 01, 2011 4:42pm

    Elemento, Inc.

    57 posts

    ...one way

    {exp:channel:entries channel="extra" sort="asc" disable="categories|member_data|pagination|trackbacks" dynamic="no" url_title="{segment_2}"} 
    {embed='includes/header' page_title="{title}"}
    
    ...body
    
    ...footer
    
    {/exp:channel:entries}


    and in includes.header:

    ...html
    <head>
    ...
    <title>{if "{embed:page_title}" != ""}{embed:page_title} :{/if} {site_name}</title>
    ...
    </head>

    We also use STRUCTURE which has a good title_trail functionality

  • #5 / Sep 03, 2011 1:39pm

    John St-Amand

    865 posts

    Osze - here’s my example for you:

    In my template:

    {exp:mx_jumper:out_global}
    
    {!-- HEADER EMBED WITH INJECTED ENTRY-SPECIFIC DATA --}
    {embed="{my_embedded_template_group}/.global-html-header" 
        the_entry_title="{entry_title}" 
        the_entry_seo_title="{entry_seo_title}" 
        the_entry_seo_description="{entry_seo_description}" 
        the_entry_seo_keywords="{entry_seo_keywords}" 
        the_section_title="{my_template_group_title}" 
        the_template_group="{my_template_group}"
        }
    {!-- [END] HEADER EMBED WITH INJECTED ENTRY-SPECIFIC DATA --}
    
    <body>
    
    The rest of my site content…
    
    {exp:channel:entries channel="example" limit="20" orderby="date" sort="desc" disable="whatever|you|can|live|without" dynamic="no"}
    
    
                {exp:mx_jumper:put name="entry_title"}{title}{/exp:mx_jumper:put}
                {exp:mx_jumper:put name="entry_seo_title"}{example_seo_title}{/exp:mx_jumper:put}
                {exp:mx_jumper:put name="entry_seo_description"}{example_seo_description}{/exp:mx_jumper:put}
                {exp:mx_jumper:put name="entry_seo_keywords"}{example_seo_keywords}{/exp:mx_jumper:put}
    
                Then whatever I intend to do with my channel entries…
    
    
    {/exp:channel:entries}
    
    {/exp:mx_jumper:out_global}
    
    </body>
    </html>

    And in my embedded header:

    <html>
    <head>
    
    {!-- SEO META DATA --}
    
            <title>{if '{embed:the_entry_seo_title}' != ""}{embed:the_entry_seo_title}{if:elseif '{embed:the_entry_title}' != ""}{embed:the_entry_title}{if:else}{site_meta_title}{/if}{if '{embed:the_channel_title}' != ""} | {embed:the_channel_title}{/if}{if '{embed:the_section_title}' != ""} | {embed:the_section_title}{/if} | {site_name}</title>
        
        <meta name="description" content="{if '{embed:the_entry_seo_description}' != ""}{embed:the_entry_seo_description}{if:else}{site_meta_description}{/if}" />
        <meta name="keywords" content="{if '{embed:the_entry_seo_keywords}' != ""}{embed:the_entry_seo_keywords}{if:else}{site_meta_keywords}{/if}" />
    
    
    {!-- [END] SEO META DATA --}
    </head>

    ... among other things, but this is the basics.  You’ll notice that I also use simple conditionals to determine whether the embedded variables contain content and if they do, use them, while if they don’t, I fall back to snippets I create for site-wide defaults that I put in their own “site settings” channel so the client can manipulate them too.  And as you can see, in my channel field group I use a channel-specific set of three SEO fields - one for an alternate title, one for a description and one for keywords (and in my case, i usually use DevDemon’s awesomely free Tagger add-on for that field).  I also add a few other items to my embedded variables - like a template group title and a section title - which are then again only used if they are in fact passed to the html header.  These are for showing hierarchy rather than just a site name and an entry url title.

    I’m certainly not saying it’s a best practice, but it’s worked very well for me on numerous sites.  Granted, there’s quite a number of conditionals in there, but I’ve kept them very simple so it doesn’t seem to slow things down and with Jumper’s help, it’s only calling the channel module once.

    I hope that’s useful to you.

  • #6 / Nov 07, 2011 1:40pm

    eyevariety

    158 posts

    @Osze I am pretty perfomance obsessed too and I found the best results using Template Morsels.  It is waay faster than an embed.  I too would like to use Jumper/Snippets- because that would be even faster!

  • #7 / Jan 19, 2012 2:54pm

    Osze

    42 posts

    Thanks for the great advices.

    But I’ve actually gone back to old school using:

    {exp:channel:entries channel="info_pages" orderby="date" disable="categories|pagination|member_data" limit="1"}
    {embed="embeds/.html_top" title="{info_pages_seo_title} | Exchange Student World" description="{info_pages_description}"}
    {/exp:channel:entries}

    The reason for that is CACHE! I can’t cache my template with MX_jumper. :(

    I would love to try getting my titles with Lows AWESOME discovery that Preload Replace can be used with Snippets. That would give me the exact same functionality but with Snippets. SOO COOL! 😊

    Read more about it here:
    http://gotolow.com/blog/snippets-and-preload-replace-variables

  • #8 / Jan 19, 2012 2:58pm

    eyevariety

    158 posts

    Only thing I would say is that wiith snippets- you shouldnt need multiple channel:enntries tags - you should be able to wrap everything in one tag. 

    Template morsels is still handy because template caching means that first load is unbearble slow if thats all you are using.

  • #9 / Jan 19, 2012 3:06pm

    Osze

    42 posts

    Yeah, maybe template caching is not worth playing with when the site is fast. 😊

    On my first page:
    Loading Time: Base Classes   0.0125
    Controller Execution Time ( Ee / Index )  0.2487
    Total Execution Time   0.2614

    = 47 queries

    And it’s actually fairly advanced with many {exp:channel} and member functionality.
    My site is now under dev but you can find it on:
    http://www.phdlibrary.com if you want to check it out.

    The biggest WOW factor was when I changed from a normal hosting company to my own Rackspace Server. What a different!!!

     

  • #10 / Jan 19, 2012 3:09pm

    eyevariety

    158 posts

    Very slick site!  So is the whole box yours?  I have only done a few sites completely dedicated and none were so intense that they really utilized it.

  • #11 / Jan 19, 2012 3:20pm

    Osze

    42 posts

    I’m not sure if you I understood you completly - the whole box?

    If you are talking about the RackSpace Server than I’m not using a dedicated server. I’m on their Cloud server! It’s absolutly wonderful. Super support, really. I’ve never done anything with servers before I began with Rackspace but the support helped me through the entire way to set it up. And I was asking some (ALOT!) of insanely stupid questions. 😉

  • #12 / Jan 20, 2012 8:19am

    I’ve used the SEO lite plugin on ifknorrkoping.se, works like a charm.

    {exp:seo_lite use_last_segment='yes'
            title_postfix='{embed:title_postfix}'
            default_title='{embed:default_title}'
            default_keywords='{embed:default_keywords}'
            default_description='{embed:default_description}'
    }
  • #13 / Jan 20, 2012 8:52am

    Osze

    42 posts

    haha it’s a small world. I’m a big IFK Norrköping fan. 😊

    And I’ve ofcourse noticed the new IFK site. You did an awesome job, I’m super impressed with the responsive design using media queries and much more! But why a click on “the almost impossible link” to see the latest news? Ok, it looks better! 😊

    You are killing this discussion with SEO Lite. I’ve always worked after the notion “not using addons if I don’t have too” and that’s I’ve never really read about SEO Lite and NSM Better Meta.
    But SEO Lite really looks sweet. One query is impressive.

    Have you stumble upon any problems in flexability using SEO Lite or is it perfect? 😊

  • #14 / Jan 20, 2012 9:04am

    hehe, yeah it’s small indeed 😉
    Thanks, we’ve chose to hide the latest news to save some space as the layout will change slightly before and during games. There’s still some small fixes to be done to fine tune the responsive layout though.

    So far I haven’t noticed any problems with SEO lite, It’s flexible and i like how it defaults if the fields are empty. I would recomend it, but then i’m using quite a few plugins, the performance loss isn’t big enough to compensate for the extra time it might have taken to do the same functionality natively. 😊

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases