From FamilySearch Wiki
Jump to: navigation, search

A page should be divided into sections, using the section heading syntax. For each page with more than three section headings, a table of contents (TOC) is automatically generated.


The same guidelines apply for titles of sections as for naming conventions of articles (see FamilySearch Wiki:Naming conventions). The titles should be easily recognizable, be brief and chosen to avoid implying a viewpoint.

Creating sections

Sections are created by creating their headings, as below.

*If only 2 equal signs are used the text will not wrap around images causing white spaces.
*This is the preferred way of starting new sections.
*Only create a sub-section if there are 2 or more sub-sections within the section.

Headings of sections (including subsections) should be unique on a page. Using the same heading more than once on a page causes problems:

A section of a page can be a transclusion of a separate page or template. This in effect gives the section its own separate edit history (i.e., the page history of the transcluded page) and also allows registered users to watch it separately.

In a page calling a template with sections, the sections in the template are numbered according to their position in the rendered page, e.g. if the template tag is in the third section, then the first section of the template is numbered four. Any text in the template before its first section shows up as part of the section with the template tag, and any text after the tag before a new heading shows up as part of the last section of the template. This may be done deliberately, but should be avoided (see also below).

Table of contents (TOC)

For each page with more than three headings, a "table of contents" (TOC) is automatically generated from the section headings, unless:

Forcing the TOC to appear

When either __FORCETOC__ or __TOC__ (with two underscores on either side of the word) is placed in the wikitext, a TOC is added even if the page has fewer than four headings.

With __TOC__, it is placed at the same position where this code is placed. This allows any positioning, e.g. on the right or in a table cell (see below).

__FORCETOC__ is similar to the TOC __TOC__ except that it can be placed anywhere on the page and the TOC will still be placed before the first section heading.

Hiding the TOC

Using __NOTOC__ it is possible to disable the normal table of contents. Section links, as explained below, allow creating compact ToCs, e.g. alphabetical [[#A|A]] [[#B|B]] etc.

Changing where the TOC appears

There may be some introductory text before the TOC, known as the "lead". __TOC__ can be used to place the TOC at the top of the page before any text avoiding the need to insert a meaningless heading just to position the TOC correctly. Additionally, __TOC__ can be used anywhere on the page to force the TOC to appear at a specific location.

Forcing the TOC to appear on the right

This Table of Contents can be forced to appear on the right hand side of the screen using the template {{TOC right}}.

Alternatively the code below can be used::

  {| align="right"
  | __TOC__

Limiting the number of headings

The TOC's depth can be limited by the use of Template:TOClimit. This template can reduce the number of "header levels" visible to the reader – thus avoiding the problem of an overwhelming TOC when an article has many headings and sub-headings.

Globally limiting the TOC depth

It is possible to limit the depth of sub-sections to show in the TOC globally using $wgMaxTocLevel. If configuration setting $wgMaxTocLevel in LocalSettings.php is set to 3 for example, only first and second level headings show up in the TOC. Until version 1.10.0rc1, there is a bug in the parser making a limited TOC display incorrectly. A simple solution is proposed in bug report 6204.

Section linking

In the HTML code for each section there is an anchor HTML element "a" with both "name" and "id" attributes holding the section title. This enables linking directly to sections. These section anchors are automatically used by MediaWiki when it generates a table of contents for the page, and therefore when a section heading in the TOC is clicked, it will jump to the section. Also, the section anchors can be manually linked directly to one section within a page.

The HTML code generated at the beginning of this section, for example, is:

<p><a name="Section_linking" id="Section_linking"></a></p>
<h2>Section linking</h2>

A link to this section (Section linking) looks like this:

[[Help:Section#Section_linking|Section linking]]

To link to a section in the same page you can use [[#section name|displayed text]], and to link to a section in another page [[page name#section name|displayed text]].

The anchors disregard the depth of the section; a link to a subsection or sub-subsection etc. will be [[#subsection name]] and [[#sub-subsection name]] etc.

An underscore and number are appended to duplicate section names. E.g. for three sections named "Example", the names (for section linking) will be "Example", "Example_2" and "Example_3". However, after editing section "Example_2" or "Example_3" (see below), one, confusingly, arrives at section "Example" from the edit summary.

If a section has a blank space as heading, it results in a link in the TOC that does not work. For a similar effect see NS:0.

To create an anchor target without a section heading, you can use a span: <span id="anchor_name"></span> but this won't work with old browsers.


For linking to an arbitrary position in a page see Advanced Linking (anchors).

Section editing

Sections can be separately edited by clicking special edit links labeled "[edit]" by the heading, or by right clicking on the section heading, depending on the preferences set. This is called "section editing feature" (Preferences -> Editing -> "Enable section editing via [edit] links"). Section editing feature will take you to an edit page by a URL such as

Note that here section numbers are used, not section titles; subsections have a single number, e.g. section 2.1 may be numbered 3, section 3 is then numbered 4, etc. You can type in URLs in the address bar of your browser.

This is convenient if the edit does not involve other sections and one needs not have the text of other sections during the edit (or if one needs it, open the section edit link in a new window, or during section editing, open the main page in a different window). Section editing alleviates problems of large pages.

"__NOEDITSECTION__" anywhere on the page will remove the edit links. It will not disable section editing; right clicking on the section heading and the url still work.

Inserting a section can be done by editing either the section before or after it, merging with the previous section by deleting the heading. In these cases the preloaded section name in the edit summary is not correct, and has to be changed or deleted.

Adding a section at the end

Adding a section at the end can also be done with a URL like . On talk pages and pages with in the wikitext the code __NEWSECTIONLINK__ a special link labeled with the Template:Msg, e.g. "+" or "Post a new comment", is provided for this. In this case, a text box having as title the Template:Msg, e.g. "Subject/headline", will appear and the content you type in it will become the section heading. There is no inputbox for the edit summary, it is automatically created according to the pattern of Template:Msg, where "/* $1 */" represents a right arrow linking to the new section and, with CSS-class "autocomment", the name of the section followed by " - ". In the case of the default of message newsectionsummary this is followed by the text "new section". The user cannot provide more text for the edit summary than just the header itself (use the method mentioned earlier if that is desired).

Parameter "preloadtitle" provides initial content of the "Subject/headline" box, e.g.:

It can be edited before saving.

See also linking in an edit summary to a section, and "Post a comment" feature.


Subsections are included in the part of the section that is edited. Section numbering is relative to the part that is edited, so on the relative top level there is always just number 1, relative subsections all have numbers starting with 1: 1.1., 1.2, etc.; e.g., when editing subsection 3.2, sub-subsection 3.2.4 is numbered 1.4. However, the heading format is according to the absolute level.

Editing a page with large sections

If a page has very large sections, or is very large and has no division into sections, and one's browser or connection does not allow editing of such a large section, then one can still:

If one can view the wikitext of a large section, one can divide the page into smaller sections by step by step appending one, and finally deleting the original content (this can be done one large section at a time). Thus temporarily there is partial duplication of the content, so it is useful to put an explanation in the edit summary.

Sections within parser functions

When conditionally (using a Parser Function) transcluding a template with sections, edit links of this and subsequent sections will edit the wrong section or give the error mesage that the section does not exist (although the page (including TOC) is correctly displayed and the TOC links correctly). This is because for the targets of the edit links the content of conditionally included templates is considered part of the page itself, and the sections are counted after expansion.

Thus the edit links of the sections of the included template link to the page itself instead of the template, and the edit links after the included template link to the correct page but the wrong section number.

Generally conditional sections give such a complication.

The problem does not occur when transcluding a template with a conditional name (which has more advantages). Use >Template:void (backlinks, edit) for the template to transclude to produce nothing.

Editing a footnote

To edit a footnote rendered in a section containing the code <references />, edit the entire page as the "References" section will not display the reference which is located in another section on the page.

Sections vs. separate pages vs. transclusion

Advantages of separate pages:

Advantages of one large page with sections:

An alternative is composing a page of other pages using the template feature (creating a compound document by Transclusion). This allows easy searching within the combined rendered page, but not in the combined wikitext. As a disadvantage, a title for each page has to be provided. For the pre-expand include size limit this is disadvantageous even compared with one large page: the pre-expand include size is the sum of the pre-expand include sizes of the components plus the sum of sizes of the wikitexts of the components.

See also

Help-content.png Questions?
Visit the Get Help to receive help with contributing to the Wiki.


Retrieved from ""