Brainstorms and Raves - Mobile

skip to navigation

Relative vs. Absolute URLs
04:13 PM - Sep 7, 2003

As much as I love using Movable Type, a few things have bothered me about MT, too, such as MT generating absolute URLs for internal links when relative URLs should be used. Stepan Riha’s MTRelativeURL plugin is an incredibly easy way to generate relative URLs with MT, thankfully, wherever the plugin tags are used.

For example, a permalink generated by Movable Type includes the site URL, such as this:

<a href="http://brainstormsandraves.com/
entry_permalink/" rel="bookmark" title="Entry title">
Permalink</a>

Root relative links should instead be used for nearly all of a site’s internal sites, such as this:

<a href="/entry_permalink/" rel="bookmark" title="Entry title">Permalink</a>

An exception where absolute URLs are required is within RSS feeds for which absolute URLs are currently still needed. So don’t use the MTRelativeURL plugin tags within your MT RSS templates, at least not unless the absolute URL requirement changes at some point.

There are at least a couple of ways to use the MTRelativeURL plugin for an entry’s permalink, but one way is to surround the <$MTEntryLink$> tag with the MTRelativeURL tags:

Before:
<a href="<$MTEntryLink$>" rel="bookmark" title="<$MTEntryTitle remove_html="1"$>">Permalink</a>

After:
<a href="<MTRelativeURL><$MTEntryLink$>
</MTRelativeURL>" rel="bookmark" title="<$MTEntryTitle remove_html="1"$>">
Permalink</a>

Here’s the same example without the text wrapping: MTRelativeURL Example

See Stepan Riha’s MTRelativeURL plugin page for more information and details in its use.

Agh! Help! They’re Everywhere!

There are potentially quite a few internal links throughout your site in which MT is generating absolute URLs, not just the permalinks. This is also a very unnecessary waste of bandwidth, as I write about below in Save Bandwidth.

Over the weekend I added MTRelativeURL tags for MT-generated internal links throughout my templates. It’s an easy task that doesn’t take long while having tremendous benefit. Here’s a partial list from my own templates to give you an idea of where to look in your templates:

Main page, individual entry pages:
Permalinks
Related Categories links
Comments / Trackbacks links
Previous, Next links
Main Archive page:
Archives by Category links
Archives by Month links
Category Archive pages:
Entry links

[Cover: Speed Up Your Site, by Andy King] Save Bandwidth

One of the benefits of using relative URLs is shaving off some webpage file size, saving some or a lot of bandwidth, depending on the page.

You can improve file size, save bandwidth, and have more efficient pages in other ways, too, such as getting rid of white-space within markup and content, optimizing images, using external style sheets to manage an entire site, and more. I highly recommend Andy King’s site optimization book, Speed Up Your Site.

More on Relative and Absolute URLs

A couple of helpful resources to understand relative and absolute URLs and why they matter:

top

[Home: Mobile · Main]
[Mobile Archives: 2008 · 2007 · 2006 · 2005 · 2004 · 2003 · 2002 · 2001 · 2000
All years (one page)]
[Main Archives]

Copyright © 2000-2008 Shirley E. Kaiser, M.A., SKDesigns. All Rights Reserved.