notes.husk.org. scribblings by Paul Mison.

2008-10-23

Fix Yr Tumblr Template Titles

text 12:42:00

I’m a big fan of meaningful titles. Not only do they make your web browser’s history easier to navigate, but they also give bookmarks - both local and shared - meaningful, and they’re good for IRC and IM conversations too. I’m told they’re important for SEO, but I’m not exactly bothered about that one.

When I first published my custom theme for notes.husk.org, the title was fairly useful:

<title>notes.husk.org. 
     {block:PostSummary}{PostSummary}{/block:PostSummary}</title>
     

This gives the index page a title of notes.husk.org (yes, I should be using {Title}, but I don’t care to make this theme public- yet), and if it’s a single post (for example, my previous text post), it also puts the post’s name into the title, so you end up with “notes.husk.org. Irony in Stamps”.

I decided to add a full stop after the PostSummary, but then considered some other cases. For example, what about archive by date pages, like this one? Well, there’s a set of tags for use when you’re on such pages for pagination, and you can (ab)use them like so:

{block:DayPagination} noted on {block:Posts}
     {block:NewDayDate}{Year}-{MonthNumberWithZero}-{DayOfMonthWithZero}.
     {/block:NewDayDate}{/block:Posts}{/block:DayPagination}
     

It’s not terribly clean, because you need to loop over the posts to get the day out, but it is there. However, that still leaves the other sort of pagination, the straightforward 10-per-page sort. That’s easy enough to deal with, though:

{block:PreviousPage} archive page {CurrentPage} 
        of {TotalPages}.{/block:PreviousPage}
        

Here, PreviousPage is only invoked if you’re not on the newest (ie front) page, so the title there is kept short. Thankfully this is more straightforward than the date archive version, but I might end up tweaking the wording a bit (especially as Tumblr has its own concept of “archives”, which are very pretty but not templatable).

Finally, there’s tag pages, which I don’t expose (edit: now I do, on single-post pages only) but you can still get to anyway. These are pretty straightforward:

{block:TagPage}tagged {Tag}.{/block:TagPage}

So that’s it. All the pages on notes.husk.org now have a unique title, even the ones that don’t have exposed navigation. Nifty, huh? The full block, in case you want to work with it, is as follows. Have fun!

<title>notes.husk.org. 
    {block:PostSummary}{PostSummary}.{/block:PostSummary}
    {block:DayPagination} noted on {block:Posts}
      {block:NewDayDate}{Year}-{MonthNumberWithZero}-{DayOfMonthWithZero}.
      {/block:NewDayDate}{/block:Posts}
    {/block:DayPagination}
    {block:PreviousPage} archive page {CurrentPage} of {TotalPages}.
      {/block:PreviousPage}
    {block:TagPage}tagged {Tag}.{/block:TagPage}</title>
    

what

more

posts

tags

notes (1)

  1. blech posted this