Harvard citation templates like {{Sfn}} are prone to problems with their automatically generated links (see [1] for an extreme example). User:Ucucha/HarvErrors.js (based on User:Svick/HarvErrors.js) checks these links for validity and displays an error message for incorrect links. In addition, it checks for citations that are set up to receive links, but do not have any pointing to them.
For example, the following code produces an incorrect link and a citation without anything pointing to it:
Text{{Sfn|Smith|2011|p=9}} {{reflist}} ==References== *{{cite book|last=Smith|first=John|year=2010|title=A Book|publisher=A Publisher}}
With the script installed, this looks as follows (if you already have the script installed, you will see duplicate messages):
Text[1]
- ^ Smith 2011, p. 9. Harv error: link from CITEREFSmith2011 doesn't point to any citation.
References
[edit]- Smith, John (2010). A Book. A Publisher. Harv warning: There is no link pointing to this citation. The anchor is named CITEREFSmith2010.
Installation and customization
[edit]To install the script, add:
importScript('User:Ucucha/HarvErrors.js');
to Special:MyPage/common.js.
If installed correctly, you will see a red error message in this note[1]
If you don't see an error message, you may still need to bypass your cache.
Hiding "There is no link pointing to this citation" messages
[edit]The check for full citations that have no associated short citations pointing to them is a warning that often requires no action because full citations do not always need short citations. For example, the citation may be in a "Further reading" section, or Harvard citations may not be used in an article. To disable warnings that a long citation is present without a corresponding short citation, add the following to Special:MyPage/common.js, on a new line:
window.checkLinksToCitations = false;
When reviewing articles, this means you will have to check manually that each full citation used as a source has a corresponding short citation, if appropriate.
Fixing problems
[edit]The problems caught by this script often have one of the following causes:
- The work cited in the Harvard citation is not in the list of references. In this case, add e.g.
*{{cite book |last=Smith |first=John |year=2010 ...}}
to the list. - The work cited is in the reference list, but has
|ref=
set to something other than the defaultharv
(which is set by all{{cite xxx}}
and {{citation}} templates by default). - The author(s) or year in the Harvard citation and the citation in the reference list do not match exactly. For example, the spelling of one of the names may be incorrect, or the year in the short and full citations may not match.
- A Harvard citation was copied from one article to another, but the matching full citation from the first article's reference list was not copied.