Template:comic/doc
|
This documentation page is transcluded inside Template:comic as its documentation, so everyone can edit it. |
The template {{comic}} has an associated sandbox, available at {{comic discussion/sandbox}}.
See also {{comic discussion}} and {{comic discussion/sandbox}}.
{{comic}} generates the infobox displayed at the top of every explanation page. It renders the title and image, builds the navigation buttons (previous comic, next comic, and external link to xkcd.com), displays the title text, and automatically categorises the page by year, month, and weekday. The template is wrapped in <includeonly>, so it produces no visible output on the template page itself.
Usage[edit]
{{comic
| number =
| date =
| title =
| titletext =
| image =
| imagesize =
| noexpand =
| before =
| custom =
| ttstyle =
| bodystyle =
| bodyclass =
| extra =
| ldomain =
| lappend =
| ognumber =
| oglink =
| ogtitle =
| ogttlabel =
| ogprev =
| ognote =
| ognext =
}}
The same block with brief notes for parameters that are not self-explanatory:
{{comic
| number =
| date = Month d, yyyy; omit if undated or unreleased
| title =
| titletext =
| image = filename without File: prefix
| imagesize = e.g. 350px (width) or x400px (height)
| noexpand = true to hide "Click to enlarge"
| before = wikitext inserted before the image, e.g. a skip link
| custom = replaces image entirely with arbitrary wikitext
| ttstyle = inline CSS for the titletext span
| bodystyle = inline CSS for the outer table
| bodyclass = HTML class for the outer table
| extra = yes to categorise under Extra comics instead of All comics
| ldomain = subdomain; defaults to www (e.g. blog for blog.xkcd.com)
| lappend = URL path appended to the domain (required when number is absent)
| ognumber = position in the original LiveJournal order; activates LJ navbar
| oglink = URL to the original LiveJournal post
| ogtitle = comic's original LiveJournal title
| ogttlabel = overrides the "Original title" label
| ogprev = wiki page number of the predecessor in LJ order
| ognote = overrides "(Original order)" in the LJ navbar
| ognext = wiki page number of the successor in LJ order
}}
Parameters[edit]
Core parameters[edit]
number- The comic's number on xkcd.com. Drives the external link in the navigation bar, the previous and next buttons (computed as
number − 1andnumber + 1), and the page's sort key and date categories. Required in normal circumstances; omit only when the comic has no numeric ID (see below).
title- The comic's display title, shown in bold small-caps above the image. Wherever the template is transcluded, the title is automatically rendered as a wikilink: to
number: titlefor numbered comics, or to a page namedtitlefor unnumbered ones. If the target page does not exist, the title falls back to plain text.
image- Filename of the comic image as uploaded to the wiki, without the
File:prefix (e.g.,suspension_bridge_2x.png). Whentitletextis also set, the image is displayed with it as the hover/alt text.
date- First publication date, written as
Month d, yyyy(e.g.,January 1, 2006). Used to categorise the page by year (Comics from 2006), month (Comics from January), and weekday (Friday comics). Omit if the comic is undated or not yet released.
Title text and image options[edit]
titletext- The hover text shown on xkcd.com. Displayed below the image in a slightly larger font, labelled "Title text:".
ttstyle- Optional inline CSS applied to the title-text span. Rarely used.
imagesize- Constrains the displayed image size. Use a plain value (e.g.,
350px) to cap the width, or prependx(e.g.,x400px) to cap the height. If the value exceeds the actual image dimensions, the image will be stretched. Typically paired withnoexpand.
noexpand- Set to
trueto suppress the "Click comic to enlarge" notice, normally used alongsideimagesize.
before- Wikitext inserted between the title row and the image. Used on very long or tall comics (e.g., 1732: Earth Temperature Timeline) to provide a skip link:
[[#Explanation|↓ Skip to explanation ↓]].
custom- Replaces the image entirely with arbitrary wikitext. Used for comics that are text-only, interactive, or otherwise unsuitable for a standard image embed.
Layout and categorisation[edit]
bodystyle- Inline CSS applied to the outer wrapper
<table>.
bodyclass- HTML class attribute added to the outer wrapper
<table>.
extra- Set to
yesto categorise the page under Category:Extra comics instead of Category:All comics. Either way, the page is also added to Category:All pages.
Unnumbered and off-site comics[edit]
When a comic has no numeric ID, or links somewhere other than xkcd.com/number, the navigation bar switches to "wide link mode" and builds the URL from the two parameters below.
lappend- The URL path appended to the domain. For example, for
blog.xkcd.com/2009/07/13/loss/, set this to2009/07/13/loss/. Required whennumberis absent.
ldomain- The subdomain used in place of
www(e.g.,blogforblog.xkcd.com). Defaults towww. The resulting URL ishttps://ldomain.xkcd.com/lappend.
Early LiveJournal comics[edit]
Before xkcd.com launched on January 1, 2006, Randall posted comics on the "xkcd_drawings" LiveJournal account. The 44 comics posted there were later transferred to xkcd.com in a completely different order, with only 3: Island (sketch) keeping the same number. For these early comics, from 7: Girl sleeping (Sketch -- 11th grade Spanish class) through 55: Useless, the template can display a second white navigation bar below the image to allow browsing them in their original LiveJournal order. This feature is activated only when ognumber is set. See LiveJournal for full historical background.
ognumber- The comic's position in the original LiveJournal posting order. Setting this activates the secondary white navigation bar.
oglink- URL to the original LiveJournal post, typically a Wayback Machine archive link. Required when
ognumberis given.
ogtitle- The comic's original title on LiveJournal, displayed in small-caps below the main title and preceded by "Original title:". Required when
ognumberis given.
ogttlabel- Overrides the "Original title" label. Spaces in the value are automatically converted to non-breaking spaces. Rarely used.
ogprev- Wiki page number of the previous comic in LiveJournal order. Required when
ognumberis given; omitting it will display a red error message in its place.
ognext- Wiki page number of the next comic in LiveJournal order. Required when
ognumberis given; omitting it will display a red error message in its place.
ognote- A short parenthetical shown next to the original number in the white navigation bar. Defaults to "(Original order)". Rarely used.
Examples[edit]
Standard comic[edit]
| Suspension Bridge |
Title text: As a first step, they can put in a secondary deck, to help drivers try it out and find out how fun the jumps are. After a while no one will use the old flat deck and they can remove it. |
{{comic
| number = 3048
| date = February 7, 2025
| title = Suspension Bridge
| image = suspension_bridge_2x.png
| imagesize = 362x365px
| noexpand = true
| titletext = As a first step, they can put in a secondary deck, to help drivers try it out and
find out how fun the jumps are. After a while no one will use the old flat deck and they can
remove it.
}}
Early LiveJournal comic[edit]
| Malaria |
| Title on LiveJournal: Malaria |
![]() Title text: The malaria party was David's idea. Caption on LiveJournal: Current Mood: Credit to David for this one |
{{comic
| number = 51
| date = January 18, 2006 <!-- The comic was released three days earlier on xkcd.com than on LiveJournal (21/1 2006). We use the earliest possible day-->
| title = Malaria
| ognumber = 49
| ogtitle = Malaria
| ogttlabel = Title on LiveJournal
| oglink = https://web.archive.org/web/20060529063441/http://xkcd-drawings.livejournal.com/#:~:text=1%3A43%20am-,Malaria,-Current%20Mood%3A
| ogprev = 54
| ognext = 52
| image = malaria.jpg
| titletext = The malaria party was David's idea.<br><br>''<span class="plainlinks">[https://web.archive.org/web/20060529063441/http://xkcd-drawings.livejournal.com/#:~:text=1%3A43%20am-,Malaria,-Current%20Mood%3A Caption on LiveJournal</span>]:'' <small>'''Current Mood:''' ''Credit to David for this one''</small>
}}
Kitchen-sink example[edit]
Uses every compatible parameter simultaneously. Omitted: custom (mutually exclusive with image), and extra, ldomain, lappend (only for extra or unnumbered comics).
| Pi Equals |
| LiveJournal title: Pi equals |
| ↓ Skip to explanation ↓ |
Title text: My most famous drawing, and one of the first I did for the site |
{{comic
| number = 10
| date = September 30, 2005
| title = Pi Equals
| ognumber = 4
| oglink = https://web.archive.org/web/20070927001941/http://xkcd-drawings.livejournal.com/...
| ogtitle = Pi equals
| ogttlabel = LiveJournal title
| ogprev = 9
| ognote = LJ order
| ognext = 11
| before = [[#Explanation|↓ Skip to explanation ↓]]
| image = pi.jpg
| imagesize = 350px
| noexpand = true
| titletext = My most famous drawing, and one of the first I did for the site
| ttstyle = font-style: italic;
| bodyclass = livejournal-comic
| bodystyle = border: 2px dashed #006622;
}}
