Not a developer? Go to MovableType.com

MT5 Documentation

Archive File Path Specifiers

Archive File Path Specifiers are used when creating Archive Mappings and formulating links to files published by the Archive Templates within the system.

Archive mappings are the paths Movable Type creates when it publishes a files using an archive template. Archive mappings determine the URLs of all file published by the archive templates: entries, pages, monthly archives, etc.

One template may have multiple mappings; the author and author-monthly files may be published by the same template and have some conditional logic (mt:If, mt:Else, mt:Unless, etc) using archive template variables.

To create a "Monthly" archive mapping such as:

2008/12/index.html

...use %y for a 4-digit year, %m for a 2-digit month, and %i for the default index file name. Separate the specifiers with forward slashes denoting the path:

%y/%m/%i

To create a "Category" archive mapping such as:

category/sub-category/index.html

...use %-c for a dash-separated category path and and %i for the default index file name separated by slashes like this:

%-c/%i

To create an "Entry" archive mapping like this:

2008/12/entry-basename.html

...use 4-digit year, 2-digit month, and entry basename with the archive file extension specified in publishing preferences:

%y/%m/%-f

Archive File Path Specifiers are used by various Movable Type tags that create links (such as the mt:EntryPermalink tag). When an archive mapping ends with the the directory index--a combination of IndexBasename and the archive file extension specified in publishing preferences, which is "index.html" for most servers--Movable Type will remove it from the url.

Thus if the actual paths to an entry and a monthly archive are like this:

2008/12/entry-basename/index.html
2008/12/index.html

Then Movable Type will create links (respectively) to the above files without the directory index filename:

<a href="2008/12/entry-basename/"><!-- foo entry --></a>
<a href="2008/12/"><!-- foo monthly archive --></a>

Common Archive Paths

The below archive paths suggested values in Movable Type. The default option for each archive type is in bold.

Archive Type Archive Path Specifier String
Entryyyyy/mm/entry-basename.html%y/%m/%-f
Entryyyyy/mm/entry_basename.html%y/%m/%f
Entryyyyy/mm/entry-basename/index.html%y/%m/%-b/%i
Entryyyyy/mm/entry_basename/index.html%y/%m/%b/%i
Entryyyyy/mm/dd/entry-basename.html%y/%m/%d/%-f
Entryyyyy/mm/dd/entry_basename.html%y/%m/%d/%f
Entryyyyy/mm/dd/entry-basename/index.html%y/%m/%d/%-b/%i
Entryyyyy/mm/dd/entry_basename/index.html%y/%m/%d/%b/%i
Entrycategory/sub-category/entry-basename.html%-c/%-f
Entrycategory/sub-category/entry-basename/index.html%-c/%-b/%i
Entrycategory/sub_category/entry_basename.html%c/%f
Entrycategory/sub_category/entry_basename/index.html%c/%b/%i
Pagefolder-path/page-basename.html%-c/%-f
Pagefolder-path/page-basename/index.html%-c/%-b/%i
Pagefolder_path/page_basename.html%c/%f
Pagefolder_path/page_basename/index.html%c/%b/%i
Dailyyyyy/mm/dd/index.html%y/%m/%d/%f
Weeklyyyyy/mm/day-week/index.html%y/%m/%d-week/%i
Monthlyyyyy/mm/index.html%y/%m/%i
Yearlyyyyy/index.html%y/%i
Categorycategory/sub-category/index.html%-c/%i
Categorycategory/sub_category/index.html%c/%i
Category-Dailycategory/sub-category/yyyy/mm/dd/index.html%-c/%y/%m/%d/%i
Category-Dailycategory/sub_category/yyyy/mm/dd/index.html%c/%y/%m/%d/%i
Category-Monthlycategory/sub-category/yyyy/mm/index.html%-c/%y/%m/%i
Category-Monthlycategory/sub_category/yyyy/mm/index.html%c/%y/%m/%i
Category-Weeklycategory/sub-category/yyyy/mm/day-week/index.html%-c/%y/%m/%d-week/%i
Category-Weeklycategory/sub_category/yyyy/mm/day-week/index.html%c/%y/%m/%d-week/%i
Category-Yearlycategory/sub-category/yyyy/index.html%-c/%y/%i
Category-Yearlycategory/sub_category/yyyy/index.html%c/%y/%i
Authorauthor/author-basename/index.htmlauthor/%-a/%f
Authorauthor/author_basename/index.htmlauthor/%a/%f
Author-Dailyauthor/author-basename/yyyy/mm/dd/index.htmlauthor/%-a/%y/%m/%d/%f
Author-Dailyauthor/author_basename/yyyy/mm/dd/index.htmlauthor/%a/%y/%m/%d/%f
Author-Montlyauthor/author-basename/yyyy/mm/index.htmlauthor/%-a/%y/%m/%f
Author-Monthlyauthor/author_basename/yyyy/mm/index.htmlauthor/%a/%y/%m/%f
Author-Weeklyauthor/author-basename/yyyy/mm/day-week/index.htmlauthor/%-a/%y/%m/%d-week/%f
Author-Weeklyauthor/author_basename/yyyy/mm/day-week/index.htmlauthor/%a/%y/%m/%d-week/%f
Author-Yearlyauthor/author-basename/yyyy/index.htmlauthor/%-a/%y/%f
Author-Yearlyauthor/author_basename/yyyy/index.htmlauthor/%a/%y/%f

Editing Archive Mappings

Archive Mappings are found under "Template Options" at the bottom of each archive template.

  1. Navigating to "Design > Templates".
  2. Edit an archive template such as: Entry, Entry Listing, Monthly Entry Listing, etc.
  3. At the bottom of the screen click "Template Options" to reveal the archive mappings associated with a template.

Using Template Tags in Archive Paths

Movable Type template tags can be used directly in the archive mapping.

For example, to publish entries at a URL like:

2009/September/16/basename.html

Use the mt:EntryDate tag which has additional date formats to produce the archive mapping like this:

%y/<$mt:EntryDate format="%B"$>/%d/%-f

or output the whole date and slashes using the tag:

<$mt:EntryDate format="%Y/%B/%d"$>/%-f

Warning: users should be aware that the use of template tags, while advantageous in some circumstance, carries with it some risks. There is no absolute guarantee that the output of a template tag and any combined modifier like dirify="1" will be consistent from one version to the next. If you rely on template tags in your archive mappings, please play close attention to the Movable Type change log prior to upgrading to anticipate any changes to relied upon behavior.*

Tips

  • Using a dash after the percent sign will cause the specifier to use dashes instead of underscores. If %a produces melody_nelson, then %-a would produce melody-nelson.
  • In some of the cases the uppercase variants exist and can be used to produce an alternate version of the value returned by the lowercase specifier.

Archive File Path Specifiers

%a

The author basename (<$mt:AuthorBasename$>. Example: melody_nelson

%_a

The same as %a.

%-a

The same as above except using dashes. Example: melody-nelson

%b

For individual archive mappings, this returns the <$mt:EntryBasename$>. By default, this is the first thirty characters of an entry dirified with underscores. It can be specified by using the basename field on the edit entry screen. Example: my_summer_vacation

%_b

The same as %b.

%-b

Same as the above but uses dashes instead of underscore. Example: my-summer-vacation

%_b

Same as the above but uses dashes instead of underscore. Example: my_summer_vacation

%c

The primary category/subcategory path of an entry constructed using category basenames (<$mt:SubCategoryPath$>. Example: arts_and_entertainment/tv_and_movies

%_c

The same as %c.

%-c

Same as above but using dashes. Example: arts-and-entertainment/tv-and-movies

%C

The basename of the primary category of the entry (<$mt:CategoryBasename$>. Example: tv_and_movies

%-C

Same as above but using dashes. Example: tv-and-movies

%d

2-digit day of the month. Same as <$mt:ArchiveDate format="%d"$>. Example: 09

%D

3-letter language-dependent abbreviation of the week day. Same as <$mt:ArchiveDate format="%e" trim="1"$> Example: Tue

%e

A numeric entry ID padded with leading zeroes to six digits. Same as <$mt:EntryID pad="1"$> Example: 000040

%E

The numeric ID of the entry. Same as <$mt:EntryID pad="0"$> Example: 40

%f

Archive filename with the archive file extension specified in publishing preferences. This can be used instead of %b or %i and will do the right thing based on the context. Same as <$mt:ArchiveFile$>. Example: entry_basename.html or index.html

%-f

Same as %f but using dashes. Example: entry-basename.html

%F

Same as "%f" but without the file extension. Same as <$mt:ArchiveFile extension="0"$>. Example: entry_basename

%-F

Same as "%f" but without the file extension and using dashes. Same as <$mt:ArchiveFile extension="0" separator="-"$>. Example: entry-basename

%h

2-digit hour on a 24-hour clock with a leading zero if applicable. Same as <$mt:ArchiveDate format="%H"$>. Example: 09 for 9am, 16 for 4pm

%H

2-digit hour on a 24-hour clock without a leading zero if applicable. Same as <$mt:ArchiveDate format="%k" trim="1"$>. Example: 9 for 9am, 16 for 4pm

%i

The setting of the IndexBasename configuration directive with the default file extension appended. Same as <$mt:IndexBasename extension="1"$>. Example: index.html

%I

Same as %i but without the file extension. Same as <$mt:IndexBasename$>. Example: index

%j

3-digit day of year, zero-padded. Same as <$mt:ArchiveDate format="%j"$>. Example: 040

%m

2-digit month, zero-padded. Same as <$mt:ArchiveDate format="%m"$>. Example: 07

%M

3-letter month. Same as <$mt:ArchiveDate format="%b"$>. Example: Sep or Jan

%n

2-digit minute, zero-padded. Same as <$mt:ArchiveDate format="%M"$>. Example: 04

%p

Current page number. Same as <mt:PagerBlock><mt:IfCurrentPage><$mt:Var name="__value__"$></mt:IfCurrentPage></mt:PagerBlock>

%s

2-digit second, zero-padded. Same as <$mt:ArchiveDate format="%S"$>. Example: 01

%x

File extension with a leading dot (.). Same as <$mt:BlogFileExtension$>. If a file extension has not been specified a blank string is returned. Example: .html

%y

4-digit year. Same as <$mt:ArchiveDate format="%Y"$>. Example: 2005

%Y

2-digit year with zero-padding. Same as <$mt:ArchiveDate format="%y"$>. Example: 05

Back

Leave a Comment