Template:Harvard citation/doc

Template page

The harv ("Harvard citation") template creates a short-cite in the form of "(Smith 2007, p. 22)", such as might be used in a "parenthetical" system of citation.

Template:Template link is designed to be used to create shortened footnotes, a citation style which pairs a short, author-date citation in a footnote with a complete citation in the references section at the end of the article (see example below). This citation style is used to reduce clutter in the edit window and to combine multiple citations to the same source.

Common problems and known workarounds are given in the section possible issues section below.

There are several other templates that are designed for use with shortened footnotes. They differ slightly in the way they format the author-date citation and how much of their functionality is automated. A full list of these related templates is below.

Note that the use (or even non-use) of these templates is an element of citation "style", and adding or removing them in articles with an established style should be consistent with that style. See WP:CITEVAR.

Also note that inline use of these templates, i.e. use of {{harv}} without ‎<ref>...‎</ref> tags around it, was deprecated in September 2020. See also WP:PAREN.

Usage

harv generates an "author-date" style short-cite from the following parameters:

<ref>{{harv | <last1*> | <last2> | <last3> | <last4> | <year*> | p= <page> | loc= <location> }}</ref>

with

  • <last1> – required; surname of first author or corporate author
  • <last2>–<last4> – positional parameters; surnames of next three authors; required if available in the full citation
  • <year> – required; four-digit year; may have a lowercase disambiguation letter, like 2012a
  • |p= – specific page referenced in the source (alias: |page= )
  • |pp= – comma-separated list of individual pages and / or range(s) of pages referenced in the source (alias: |pages= )
  • |loc= – in-source location when |p= and |pp= are inappropriate; may be used to supplement |p= and |pp=; information such as a section or figure number.

Typical usage is shown in the example below. The text and the footnote are connected by a bi-directional link – clicking on the superscript takes the reader to the footnote, clicking on the footnote number takes them back to the superscript. The clicking on the short citation takes them to the full citation in the references section.

Template harv is placed inside ‎<ref>...‎</ref> tags to create shortened footnotes. (Using harv outside of ‎<ref>...‎</ref> tags was deprecated in September 2020).

Markup Renders asLua error: not enough memory.

Parameters

Author(s) and year

The first four author surnames (or all authors if fewer than four; use the values from |lastN= or |authorN= ) are required, followed by the year of publication (from |year= or |date=). Authors past the fourth must be omitted or an error will result.

The possible issues section below describes workarounds for various common problems, such as large number of authors, no author name, multiple works in the same year, multiple authors with same last name and others.

Markup Renders asLua error: not enough memory.

Location in the source text

The optional parameters |p=, |pp= and |loc= can be used to indicate the location in the source, such as page numbers. For single pages, use |p=; for multiple pages (such as ranges), use |pp=. Use of |p= for multiple pages or |pp= for single pages can cause cite errors. |loc= can be used to specify a location in the source in another way, such as section numbers or chapters. The parameters |page= and |pages= exist as aliases for |p= and |pp=, respectively.

Markup Renders asLua error: not enough memory.

Additional text

The optional parameter |postscript= or |ps= can be used to change the text which appears at the end of the note in the reference list. (See § Adding additional comments or quotes and § No closing period, below.) The postscript is only effective the first time {{sfn}} is used for a particular author, year and location.

Hard-coded link names

Not available in {{sfn}} and similar templates.

The optional parameter |ref= is used to create an unusually named link from the short citation to the full citation. This parameter is usually not necessary, and it is more common to use {{sfnRef}} or {{harvid}} in the reference section. If you specify |ref=none, no hyperlink is created. However, if one does not want the link, it is always possible to simply use plain text instead of the template. The parameter |Ref= is an alias for |ref=.

Possible issues

Lua error: not enough memory.

Adding additional comments or quotes

The templates {{harvnb}} or {{harvtxt}} can be used to add quotes or additional comments into the footnote. Examples are below.

Markup Renders asLua error: not enough memory.

Lua error: not enough memory.: In the past, the use of |ps= has been advised to hold this additional information, but it is not suitable for this purpose. Two or more Lua error: not enough memory. templates with the same authors, same year, and same page, but different |ps= will result in a Lua error: not enough memory. message. This message happens because the reference names that Lua error: not enough memory. creates will be the same, but the content between the ‎<ref name="FOOTNOTE..."> tag and the ‎</ref> tag will be different. A workaround is to convert one or some of the Lua error: not enough memory. templates to Lua error: not enough memory. wrapped in ‎<ref>...‎</ref> tags.

Adding a URL for the page or location

If a specific link to the page or section is available, a URL can be added to the location or page number.

Markup Renders asLua error: not enough memory.

A citation inside an explanatory footnote

Sometimes an explanatory footnote requires a citation. Templates like Template:Template link can't be directly imbedded between ‎<ref>...‎</ref> tags, because the following message will be produced: Lua error: not enough memory..

The templates Template:Template link and Template:Template link can be used to create separate explanatory footnotes from short citations, as shown in the first example. An article that uses this technique extensively is Chinese Room.

It is also possible to use the magic word {{#tag:ref|...}} and the {{sfn}} template will work correctly inside the footnote, as shown in the second example.

Markup Renders asLua error: not enough memory.

Multiple lists of inline citations

Sometimes there is a need to create two or more separate lists of inline footnotes. For example some family trees are contained in templates, they are transluded into several biographies, and they have their own self contained citations (see Template:Houston family tree and the article Margaret Lea Houston).

To facilitate this, while the main page uses the standard 1,2,3 footnote counting, it is common for family trees to use the efn template with a group parameter set—for example Lua error: not enough memory. (lower-greek). The efn templates are text templates, to link some or all of the content of the efn template to a long citation template such as Lua error: not enough memory. place Lua error: not enough memory. or Lua error: not enough memory. within the efn template.

Markup Renders asLua error: not enough memory.

More than one work in a year

Where there is a need to cite more than one work by the same author published in the same year, the standard way to disambiguate such works is to add a letter suffix after the year element of the Lua error: not enough memory. template (e.g. Lua error: not enough memory. and Lua error: not enough memory.). Make sure to add the disambiguation letter to the matching full citation, (e.g. {{cite book|...|last=Smith|date=2006b}}).

Templates that use Module:Citation/CS1

When Lua error: not enough memory. is used with Lua error: not enough memory. or Citation Style 1 templates, a year-suffix letter may be added to |date= for all accepted date formats except year-initial numeric (YYYY-MM-DD). It is not necessary to include both |date= and |year= (see exception below). If both are included, |year= is used for the CITEREF anchor to be compliant with legacy citations.

|date=2013a: simple year only dates
|date=Jan 2013b or |date=Winter 2013b: month or season and year dates
|date=9 November 2013b or |date=November 9, 2013b: full dates
|date=June–July 2013c or |date=Winter–Spring 2013c: month or season ranges and year dates
|date=c. 2013d: circa year dates
|date=2024–2025f or |date=Summer 2024–25f: year ranges
|date=n.d.e: no date (n.d.)
Lua error: not enough memory.|date=2013x-11-09: not supported, the template must use |year=2013x. If month and day should be part of the citation as well, both parameters need to be given: |date=2013-11-09 |year=2013x. In this case, |date= is used for citation display and metadata purposes, and |year= for link disambiguation.
Markup Renders asLua error: not enough memory.

More than one author with the same last name

The above solution to add a letter suffix after the year element also works for multiple authors with the same last name. For example, both Richard Bushman and Claudia Lauper Bushman published books in 2006. To differentiate between the two books, the first one can be given the year "2006a" and the second one "2006b".

Large number of authors

If there are more than four authors, the first four authors' surnames (the value in |last= or |author=) are required by the template. Listing more authors is not supported. It is also possible to use the |ref={{harvid}} in the citation template, which allows a more concise citation in the article text.

Markup Renders asLua error: not enough memory.

No author name in citation template

Some sources do not have a single author with a last name, such as a magazine article or a report from a government institution. There is no consensus (in Wikipedia or among citation styles) about how to format author–date citations for works that do not have a specific author. Several choices are:

  1. For a newspaper or periodical, you may use the name of the paper and the date.
  2. For a publication by an institution, use either:
    1. The initials of the institution
    2. The name of the institution
  3. Alternatively, some style guides recommend using the title of the article.
  4. Other style guides recommend using "Anonymous" or "Anon."

An article should adopt one of these styles consistently. Using |ref={{harvid}} in the citation template can handle these cases.

Markup Renders asLua error: not enough memory.

Citation has |date= and no |year=

Either the |date= or |year= of a citation template can be matched—the template logic can extract the year from a full date. If the date parameter is not a full date, then the extraction will fail. If the link does not seem to work, it also possible to set both |date= and |year= parameters. The template will display the date and use the year for the anchor. These two examples show a year being successfully extracted from full date.

Markup Renders asLua error: not enough memory.

Using harv with {{cite comic}}

The {{cite comic}} template uses the parameter |ref= to create an anchor for the Harvard citation templates. This can be set with {{sfnRef}}, {{harvid}}, or using CITEREF directly with a concatenation of #CITEREF plus the parameters passed to the Harvard citation template.

Markup Renders asLua error: not enough memory.

Using harv with {{vcite}}

The Citation Style Vancouver family of templates use parameter |harvid= to create an anchor for the Harvard citation templates. This must be set to a concatenation of the parameters passed to the Harvard citation template.

Markup Renders asLua error: not enough memory.

Citation format does not support anchors: {{wikicite}}

In a few very rare cases, it may be impossible for the citation templates to create an anchor. Either (1) the citation is formatted with a template that does not support the |ref= parameter or (2) the source can't be described using our citation templates at all. In these cases, it is possible to use {{wikicite}} to make the anchor. (As of November 2010, there are only approximately 100 articles that require this technique.) It is also possible that (3) local editors would prefer not to use citation templates. In this case, it is important to discuss what the local editors would like to do about the bad links. It is always possible to simply remove {{harv}} or {{sfn}}, leaving plain text without links.

Markup Renders asLua error: not enough memory.

It is also possible to use ‎<cite> to achieve the same effect, but this may not be compatible with HTML 5.

Lua error: not enough memory.

Lua error: not enough memory.

No closing period: |ps=none

Using |ps=none in {{sfn}} removes the final period. Compare the two examples. Suppressing the default period (full stop) ensures consistency with Citation style 2, as produced by {{Citation}}, which does not use a trailing period (full stop) when rendering full citations. The postscript is only effective the first time {{sfn}} is used for a particular author, year, and location. |ps= will also suppress terminal punctuation. Follow-on editors who encounter 'empty' parameters can't know if a previous editor intended to leave that parameter blank. Using the keyword none is a positive indication of the previous editor's intent.

Markup Renders asLua error: not enough memory.

Wikilink to citation does not work

If an article is using this template, and nothing happens when you click on the highlighted wikilink from a Harvard style citation to a full citation at the bottom of the page, there are several possible solutions. If:

  1. The correct citation does not appear at the bottom of the article. Solution: Find the source (it may be copied from an article on a similar subject), and check that it verifies the text. If the source can't be found, tag the citation with {{citation not found}}.
  2. The correct citation appears at the bottom of the article, and
    1. The Harvard citation uses a template (such as {{sfn}} or {{harv}}):
      1. The citation uses a template from the list at Citation Style 1:
        1. The name is spelled or capitalized differently here than in the citation. Solution: check the source for the correct spelling, and use the same spelling, spacing, and capitalization in both the short and full citations.
        2. The year is different here than the citation. Solution: check the source for the correct year, and use the same year in both the short and full citations.
        3. The template has a |date= field and no |year= field, but the format of the |date= field is unusual. Solution: Try to fix the date. If the link still does not work, add |year= to the citation template. (It's okay if it has both.)
        4. The citation does not have an author's, or an editor's, last name (authors take precedence over editors). Solution: check that |ref={{harvid}} is set correctly (see below).
      2. The citation uses a Citation Style Vancouver template. Solution: check that |harvid= is set correctly (see below).
      3. The citation uses a template that does not support |ref= (See Wikipedia:Citation templates and reference anchors). Solution: Consider modifying the template to support |ref=. Alternatively, an anchor can be created using {{wikicite|id={{harvid|args}}|reference={{citation}}}}.
      4. The full citation does not use a template:
        1. It has no wikicode to create an anchor. Solution: If {{cite *}} citation templates are used liberally throughout the article, then reformat the full citation with the appropriate {{cite *}} template (and set the |ref= appropriately, if necessary). Otherwise consult with local editors on the talk page about how to proceed. Either add {{cite *}} templates and {{harv}} templates, or remove all templates, depending on what local editors prefer. A few articles use {{wikicite}} to create an anchor as an alternative to standard templates.
        2. It uses a ‎<cite>...‎</cite> span to create an anchor. Solution: remove the cite span (these are deprecated) and proceed following the recommendation immediately above.
        3. It uses {{wikicite}}. Solution: Check that the text in |id={{harvid}} matches the text in {{wikicite}}.
    2. If the Harvard citation uses a handwritten wikilink, such as [[#Reference-Smith2006|Smith (2006)]]:
      1. The citation uses a citation template which supports |ref= (See Wikipedia:Citation templates and reference anchors). Solution: Check that |ref= is set to a matching id.
      2. Otherwise, check that the reference has {{wikicite|ref=id|reference=citation}} with a matching id.

Templates that have broken wikilinks using these templates are added to the category Category:All articles with broken links to citations.

Link works but displays a no target error

When a short-cite template links to a full citation that is rendered by a template that wraps a CS1 template, like Lua error: not enough memory. (which wraps Lua error: not enough memory.), a Lua error: not enough memory. error may be displayed even when the short-cite template is valid and the link works. That is a "false positive" error. The error message can be suppressed by adding |ignore-err=yes to the template, or by adding the template {{Sfn whitelist{{---}}{{---}}{{---}}{{---}}{{---}}{{---}}{{---}}{{---}}{{---}}{{---}}{{---}}{{---}}{{---}}{{---}}{{---}}{{---}}{{---}}{{---}}{{---}}{{---}}}} with the anchor ID(s) to the article. If you are testing changes in Special:ExpandTemplates and the error message cannot be suppressed, try testing in a sandbox or user subpage instead.

Harv embedded in list-defined ref does not work

If you embed an Harv template in a list-defined reference, you may get a false-positive "missing key" error which looks like this:

A list-defined reference named ". . ." is not used in the content (see the help page).

This is a false-positive: list-defined references do not work correctly when references are nested. It is due to a long-standing bug in mediawiki software (see phab:T22707). A workaround is possible using {{sfnlink}}.

Additional bugs associated with embedding footnotes in list-defined references are known. One of them is that the reference name given in the error message will identify the wrong list-defined reference in the first false-positive error message on the page; this is tracked in T26600.

Other author–date citation templates

There are several templates used to create short citations; they differ in the use and placement of parentheses, in the separator before the page or location, and in whether a terminal full stop (period) is present:

In-text templates
Templates Aliases Example
{{Harvard citation no brackets}} {{harvnb}} Lua error: not enough memory.
{{Harvard citation}} {{harv}} Lua error: not enough memory.
{{Harvard citation text}} {{harvtxt}} Lua error: not enough memory.
{{Harvcoltxt}} Lua error: not enough memory.
{{Harvcol}} Lua error: not enough memory.
{{Harvcolnb}} Lua error: not enough memory.
{{Harvard citations}} {{harvs}} John Smith (2006, 2007) (and many other forms).
{{Harvp}} Lua error: not enough memory.
{{Harvc}} {{Citec}} (Cite several contributions/chapters in a larger work)
Article text.Lua error: not enough memory.Lua error: not enough memory. More article text.Lua error: not enough memory.Lua error: not enough memory. Even more article text.[1]

References

Lua error: not enough memory.

Sources

  • Lua error: not enough memory.
    • Lua error: not enough memory.
    • Lua error: not enough memory.
    • Lua error: not enough memory.
{{Shortened footnote template}} {{sfn}} Article text.Lua error: not enough memory.Lua error: not enough memory.
Lua error: not enough memory.
{{Sfnp}} Article text.Lua error: not enough memory.Lua error: not enough memory.
Lua error: not enough memory.
{{Sfnm}} Article text.Lua error: not enough memory.
Lua error: not enough memory.
{{Sfnmp}} Article text.Lua error: not enough memory.
Lua error: not enough memory.

Full citations can be created manually or by templates:

All of these templates have the same parameters and basic functionality. This page describes all of them except the parameters of {{sfnm}} and {{harvs}}; please see their documentation pages. Editors editing one of these templates are requested to make parallel changes to the other versions.

Applications of these templates

Harvard citation: {{harv}}

Template {{harv}} creates a parenthetical reference with a link to the full citation in the references section at the bottom of the article.

Markup Renders asLua error: not enough memory.

Lua error: not enough memory.

Shortened footnote: {{sfn}} or {{harvnb}}

Lua error: not enough memory.

Template {{harvnb}} inside a ‎<ref> span can be used to create a shortened footnote that is linked to the full citation at the bottom of the article. Template {{sfn}} (without the use of ‎<ref>) has the same effect, automatically adds a period (full stop) after the page number, and combines identical footnotes automatically.

Markup Renders asLua error: not enough memory.

In text attribution: {{harvtxt}}

Lua error: not enough memory.

Template {{harvtxt}} can be used to link an in-text attribution to the full citation at the bottom of the page.

Markup Renders asLua error: not enough memory.

Bundled citation: {{harvnb}} or {{sfnm}}

Lua error: not enough memory. Template {{harvnb}} can be used to bundle citations. {{sfnm}} also produces bundled citations.

Markup Renders asLua error: not enough memory.

Note that {{sfn}} is inappropriate for bundled citations; use {{harvnb}} or {{sfnm}}.

More exotic Harvard citations: {{harvid}} or {{harvs}}

Lua error: not enough memory.

More exotic Harvard citations can be constructed using the {{harvs}} template, such as multiple papers by the same author, using both the first and last names, links to articles about the author, and others. Any kind of unusual link can also be constructed using the idiom [[#{{harvid|parameters}}|link name]]. ({{citeref}} is a wrapper for {{harvid}} making it easier to consistently create such internal links in small superscript[n] or plain-text label styles.)

Markup Renders asLua error: not enough memory.

Some articles use this idiom [[#CITEREFid | link name ]]. See notes on implementation details below.

Variations

Using colon format: {{harvcol}}, {{harvcolnb}}, {{harvcoltxt}}

Templates {{harvcol}}, {{harvcolnb}}, and {{harvcoltxt}} use a colon to indicate the page number(s) or location.

Markup Renders asLua error: not enough memory.

Parentheses around the year: {{sfnp}} and {{harvp}}

Template {{sfnp}} puts parentheses around the year. Compare the two examples.

Markup Renders asLua error: not enough memory.

Similarly, in order to mimic Citation Style 1 citations, template {{harvp}} puts parentheses around the year.

Markup Renders asLua error: not enough memory.

Implementation notes

These templates use two elements: a wikilink in the body of the article, and an anchor in the reference section of the article. Clicking on the wikilink repositions the page at the anchor.

Citation template anchor

Lua error: not enough memory.

The most common citation templates are Citation Style 1 or Citation Style 2. By default, Module:Citation/CS1 creates an anchor ‎<a name="CITEREF"> followed by the concatenation of the following parameters:

  • last or last1 or surname or surname1 or author-last or author-last1 or author1-last or author-surname or author-surname1 or author1-surname or author or author1 or authors,
  • last2 or surname2 or author-last2 or author2-last or author-surname2 or author2-surname or author2,
  • last3 or surname3 or author-last3 or author3-last or author-surname3 or author3-surname or author3,
  • last4 or surname4 or author-last4 or author4-last or author-surname4 or author4-surname or author4,
  • editor-last or editor-last1 or editor1-last or editor-surname or editor-surname1 or editor1-surname or editor1 or editor,
  • editor-last2 or editor2-last or editor-surname2 or editor2-surname or editor2,
  • editor-last3 or editor3-last or editor-surname3 or editor3-surname or editor3,
  • editor-last4 or editor4-last or editor-surname4 or editor4-surname or editor4,
  • date, year

This covers the most common templates. Information about all of the templates is available at Wikipedia:Citation templates and reference anchors.

Use of the date parameter in place of the year parameter in citation templates is preferred.

Harvard citation wikilink

The Harvard citation templates create a wikilink to the anchor. For example Lua error: not enough memory. produces the link #CITEREFSmith2006 and Lua error: not enough memory. produces the anchor CITEREFSmith2006.

Using CITEREF directly

A few articles create a custom ID using CITEREF, either in place of the Harvard citation template (e.g. [[#CITEREFSmith2006|(2006)]]) or as a value for |ref= in the citation template. A custom ID must follow these rules:

  • Names are case-sensitive. Please do not use raNdOM capitalization.
  • Names must not be purely numeric; the software will accept something like ":31337" (which is punctuation plus a number), but it will ignore "31337" (purely numeric).
  • Names should have semantic value, so that they can be more easily distinguished from each other by human editors who are looking at the wikitext. This means that ref names like "Nguyen 2010" are preferred to names like ":31337".
  • Names must be unique. You may not use the same name to define different groups or footnotes. Try to avoid picking a name that someone else is likely to choose for a new citation, such as ":0" or "NYT".
  • Please consider keeping reference names short, simple and restricted to the standard English alphabet and numerals. If spaces are used, the following technical restrictions become relevant:
    • Quotation marks are preferred but optional if the only characters used are letters A–Z, a–z, digits 0–9, and the symbols !$%&()*,-.:;<@[]^_`{|}~. That is, all printable ASCII characters except #"'/=<>?\ and space.
    • Inclusion of any other characters, including spaces, requires that the reference name be enclosed in quotes; for example, name="John Smith". But quote-enclosed reference names may not include a less-than sign (<) or a double straight quote symbol ("), which may however be included by escaping as &lt; and &quot; respectively.
  • If CITEREF is used, then spaces in the |ref= field must be replaced with underscores
    • The quote marks must be the standard, straight, double quotation marks ("); curly or other quotes will be parsed as part of the reference name.
  • You may optionally provide reference names even when the reference name is not required. This makes later re-use of the sourced reference easier.

Examples:

  • Lua error: not enough memory.
  • Lua error: not enough memory.
  • Lua error: not enough memory.

Where cite_name is a name such as the publisher.

To avoid the sometimes difficult to remember syntax for links to CITEREF anchors, {{citeref}} can be used to create internal wikilinks with either small superscript-style labels (like this[n]) or plain free-text labels to such anchors. It can be used inside of other citations.

Note that the CITEREF prefix is necessary for the reference tooltips gadget (MediaWiki:Gadget-ReferenceTooltips.js) to detect that a link goes to a citation.

{{sfn}}'s ref name

Template {{sfn}} creates a named footnote, so that identical footnotes are combined automatically. The footnote name begins with FOOTNOTE followed by a concatenation of the arguments to {{sfn}}. E.g.: this template call Lua error: not enough memory. should have exactly the same functionality as ‎<ref name="FOOTNOTESmith200626">{{Harvnb}}‎</ref> which, in turn, has the same functionality as ‎<ref name="FOOTNOTESmith200626">[[#CITEREFSmith2006|Smith (2006)]], p. 26‎</ref>.

The ref name becomes more complicated when the page (p) parameter includes a URL, e.g. Lua error: not enough memory., which, once defined, can be called by . The "p=" and the characters |,:,.,/,?,=; are therefore stripped out of the URL.

The call to {{harvnb}} has been subst'ed for quicker load times.

Template:Wikipedia referencing

Tracking categories

[[:Category:Lua error: not enough memory.|Category:Lua error: not enough memory.]] (0)