Jump to content

Help:Section/Editing sections of included templates

From mediawiki.org

Editing sections of included templates

This section appears in Help:Section .

You can edit sections within included pages or templates. Clicking the edit link for a section takes you to the edit page of the separate page. This section (transcluded from Help:Section/Editing sections of included templates ) shows how it works.

The size of the section within the included page or template is determined by the headings in the main page where it is included. Also, texts before the first heading of the separate page is part of the section, but clicking its edit link won't show its text. Similarly, if there are texts after the template tag without a heading, you need to click the headings before the template to edit it. This section shows how it works. To ensure clarity and consistency in rendered parent pages, follow these guidelines:

  • Template structure - Avoid placing any text before the first heading within a template.
  • Handling sections - After using a template with sections, start a new section on the parent page. This prevents conflicts between template sections and parent page sections.

Additionally, consider the following practices for managing templates effectively:

  • Template heading - Sometimes it's helpful to start a template with a heading, even if it's just one section. This makes editing easier.
  • Parameter use - When editing templates, remember parameters, such as {{{1}}}, are changed in the calling page, not directly in the template. Although this may not be immediately apparent in the rendered page, providing explanatory text or an additional edit link can enhance user understanding.
  • NOEDITSECTION tag - The __NOEDITSECTION__ tag affects the template and any pages it's added to, along with other templates on the same page. Instead, consider replacing MediaWiki section header markup with HTML header markup within the template, causing the headers to remain visually consistent while avoiding recognition as editable sections. This approach eliminates the need for __NOEDITSECTION__ within the template.

For example, think of a template structured as follows:

==Template heading 1==
Content
===Template heading 2===
Content

To prevent "edit section" links from appearing when transcluding a template, add NOEDITSECTION within the template's code. However, this suppresses all "edit section" links on pages where the template is used. Alternatively, structuring the template with HTML heading tags (‎<h2>, ‎<h3>, etc.) achieves the same visual effect without affecting other sections' edit links on transcluding pages.

<h2>Template heading 1</h2>
Content
<h3>Template heading 2</h3>
Content