Template:Sidebar
| This template is used on approximately 145,000 pages. To avoid major disruption and server load, any changes should be tested in the template's /sandbox or /testcases subpages, or in your own user subpage. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. |
| This template does not display in the mobile view of Wikiversity; it is desktop only. Read the documentation for an explanation. |
| This template uses Lua: |
This template is a metatemplate for the creation of sidebar templates, i.e. boxes that are vertically aligned navigation templates. Sidebars, like infoboxes, are usually positioned on the right-hand side of a page.
{{Sidebar with collapsible lists}} is a version of {{Sidebar}} that adds collapsibility to its sections, i.e. the means to show or hide sections by clicking links beside their headings.
Templates using the classes class=navbox ({{navbox}}) or class=nomobile ({{sidebar}}) are not displayed on the mobile web site of English Wikipedia. Mobile page views account for approximately 65% of all page views (90-day average as of May 2023[update] ).
Note that w:MOS:LEAD discourages the placement of sidebars in the lead section of articles.
Usage
| {{{topimage}}} |
| {{{pretitle}}} |
| {{{title}}} |
|---|
| {{{image}}} |
| {{{above}}} |
| {{{heading1}}} |
| {{{content1}}} |
| {{{heading2}}} |
| {{{content2}}} |
| {{{heading3}}} |
| {{{content3}}} |
| …… etc …… |
| {{{below}}} |
{{Sidebar
| name = {{subst:PAGENAME}}
| class =
| wraplinks = <!-- "true" otherwise (default:) omit -->
| float =
| templatestyles =
| child templatestyles =
| grandchild templatestyles =
| outertitleclass =
| outertitle =
| topimageclass =
| topimage =
| topcaption =
| pretitleclass =
| pretitle =
| titleclass =
| title =
| imageclass =
| image =
| caption =
| headingclass =
| contentclass =
| aboveclass =
| above =
| heading1 =
| heading1class =
| content1 =
| content1class =
| heading2 =
| heading2class =
| content2 =
| content2class =
| heading3 =
| heading3class =
| content3 =
| content3class =
<!-- (omitting infinite heading/content parameters) -->
| belowclass =
| below =
| navbar =
}}
Note that :w:Wikipedia:Manual of Style/Lead section § Elements discourages the placement of sidebars in the lead section of articles, though they may be included on a case-by-case basis.
Parameters
No parameters are mandatory. If {{navbar}} links are to function correctly (unless their appearance is suppressed; see the navbar parameter below), the parameter name needs to be set (to the name of the sidebar's page). (This does not apply if the Lua module that produces {{Sidebar}}, Module:Sidebar, is being used directly.)
| Parameter | Explanation |
|---|---|
| Template:Para | Same as the Template:Para offered by {{Navbox}}. |
| Template:Para | The sidebar's name, i.e. the name following "Template:" in the title shown at the top of the sidebar's page. Required if the V T E {{navbar}} links at the bottom of the sidebar are to function correctly, unless their appearance is suppressed (see the navbar parameter below) or {{Sidebar}} is not being used as a wrapper for Module:Sidebar. When {{Sidebar}} is used as a wrapper, setting Template:Para is recommended. |
| Template:Para | Accepts the values none and left. The former aligns the box left without floating and the latter with floating behavior. The default float is right and does not need specifying. Prefer this parameter (and passing it to any using templates such as with {{Helpbox}}) to specifying your own floats in TemplateStyles.
|
| Template:Para | Use to place a title for the sidebar immediately above the sidebar. |
| Template:Para | Use to place an image at the top of the sidebar, i.e. above Template:Para (if used). Full wiki syntax is expected (i.e. [[File:...]]). To add a caption below the image, use Template:Para. Per WV:SIDEBAR this field should only be used to define a generic image for a sidebar, not to provide custom images for individual articles: sidebars are not displayed on mobile. |
| Template:Para | Use to place a line such as "Part of the X series on" before the title. |
| Template:Para | Use to place a title for the sidebar at the top of the sidebar. (If Template:Para is used, it will appear immediately below it). |
| Template:Para | Use to place an image between the Template:Para (if used) and first section. As with Template:Para, full wiki syntax is expected (i.e. [[File:...]]). To add a caption below the image, use Template:Para. |
| Template:Para Template:Para |
The nth heading / content. contentn is required if headingn is also to appear. |
| Template:Para | See #TemplateStyles. |
|
Classes can be used to make styles easier to target for TemplateStyles. Template:Para must be used for this purpose for an entire sidebar (otherwise a page with multiple sidebars may take styles intended only for one sidebar). An example for a template named "Template:Example Sidebar" might have the class Template:Para. Template:Para and Template:Para can be used to target a specific heading or content group. This should be needed only rarely. These classes can also be used for microformats. Dot before a class-name can be omitted: Template:Para. | |
| Template:Para | Same as the Template:Para offered by {{Navbox}}. (Use, for example, to add one or more portal links to the bottom of the template (shown, by default, in bold).) |
| Template:Para | When Template:Para is specified, {{navbar}} is shown at the bottom of the sidebar. Setting Template:Para or Template:Para will suppress the links showing. |
TemplateStyles
The TemplateStyles parameters Template:Para, Template:Para, and Template:Para take the pagename of a TemplateStyles page and turn it into a TemplateStyles tag. The TemplateStyles tag is a much more powerful way to add styling to a sidebar.
Some rules of use:
- Always add a template-specific class in Template:Para so that the styles added to one sidebar will not "leak" into another sidebar.
- Do not assume Template:Sidebar will continue to have a table structure (i.e., do not target
tableor any other table HTML in the TemplateStyles page). The table structure is soft-deprecated and will go away at some point in the future.
These tags are loaded in this order: Core templatestyles (Module:Sidebar/styles.css), templatestyles, child, and then grandchild, which can be used to 'cascade' the styles.
- Template:Para
- This parameter is intended for a template or module calling {{sidebar}} directly.
- Template:Para
- This parameter is intended for a template or module which calls a sidebar with Template:Para.
- Template:Para
- This parameter is intended for a template or module which calls a sidebar with Template:Para.
The canonical list of classes output with each kind of element of a sidebar (i.e. output for all Template:Para, or all cases of Template:Para) can be found in Module:Sidebar/configuration in the "class" table. The below is a non-authoritative but otherwise sufficient list for most generic styling:
.sidebar- The top-level sidebar class.
.sidebar-outer-title- The class associated with a Template:Para.
.sidebar-top-image- The class associated with a Template:Para.
.sidebar-top-caption- The class associated with a Template:Para.
.sidebar-pretitle.sidebar-pretitle-with-top-image- The classes associated with a Template:Para. Only one of these will be output per sidebar, depending on whether Template:Para is present.
.sidebar-title.sidebar-title-with-pretitle- The classes associated with a Template:Para. Only one of these will be output per sidebar, depending on whether Template:Para is present.
.sidebar-image- The class associated with a Template:Para.
.sidebar-caption- The class associated with a Template:Para.
.sidebar-above- The class associated with a Template:Para.
.sidebar-heading- The class associated with a Template:Para. Every heading will have this class.
.sidebar-content.sidebar-content-with-subgroup- The classes associated with Template:Para. Every content group will have one of these classes, depending on whether the specific content has a subgroup.
.sidebar-below- The class associated with a Template:Para.
.sidebar-navbar- The class associated with a Template:Para.
Example TemplateStyles parameter use
For an example of a sidebar which does not need to support children templates of its own (whether because it has no children or because it wants no children):
{{Sidebar
| title = Child Example
| class = sidebar-example
| templatestyles = Template:Sidebar/example/styles.css
}}
For an example of a sidebar which does have its own children and an example of one of the children (grandchild templates have a similar use):
{{Sidebar
| title = {{{title|Title Child Example}}}
| class = sidebar-example {{{class|}}}
| templatestyles = Template:Sidebar/example/styles.css
| child templatestyles = {{{child templatestyles|}}}
}}
{{Sidebar/child example
| title = Title Grandchild Example
| class = sidebar-child-example
| child templatestyles = Template:Sidebar/child example/styles.css
}}
Handling long links
{{Normalwraplink}} may be used to handle individual links that should wrap within the sidebar or otherwise need to be made to wrap, in order to prevent the sidebar from becoming too wide. Use {{normalwraplink|longlinkname}}, where Template:Para is the long link without its square brackets.
Use the Template:Para parameter to enable link wrapping (disabling Template:Codett CSS class) for the whole template.
Nesting
One sidebar template can be nested (embedded) into another one by using the Template:Para parameter. This feature can be used to create a modular sidebar, or to create more well-defined and logical sections.
| Top-level title | ||
|---|---|---|
First subsection
|
||
Second subsection
|
||
| "below" text |
{{Sidebar
| title = Top-level title
| content1 =
{{Sidebar |child=yes
| title = First subsection
| heading1 = Heading 1.1
| content1 = Content 1.1
}}
| content2 =
{{Sidebar |child=yes
| title = Second subsection
| heading1 = Heading 2.1
| content1 = Content 2.1
}}
| below = "below" text
}}
Note in the examples above that the child sidebar is placed in a content field, not a heading field. Notice also that the section subheadings do not appear in bold if this is not explicitly specified. To obtain bold section headings, move the titles to the heading field, using
| Top-level title | ||
|---|---|---|
| First subsection | ||
|
||
| Second subsection | ||
|
||
| "below" text |
{{Sidebar
| title = Top-level title
| heading1 = First subsection
| content1 =
{{Sidebar |child=yes
| heading1 = Heading 1.1
| content1 = Content 1.1
}}
| heading2 = Second subsection
| content2 =
{{Sidebar |child=yes
| heading1 = Heading 2.1
| content1 = Content 2.1
}}
| below = "below" text
}}
Deprecated parameters
The following parameters are deprecated in favor of TemplateStyles and templates/modules using them are categorized into Category:Sidebars with styles needing conversion. The category page has further conversion information.
| Parameter | Explanation | TemplateStyles replacement class |
|---|---|---|
| Template:Para or Template:Para | Additional CSS for the whole sidebar. | Class assigned to the template in Template:Para |
| Template:Para | Additional CSS for a grabbag of parameters: Template:Para, Template:Para, Template:Para, and Template:Para (for {{sidebar with collapsible lists}}). | See related parameters for targeting pretitle, title, all headings, and all lists. Applies before the specific style parameter so must be placed above that parameter's declarations if any in the TemplateStyles sheet. |
| Template:Para | Additional CSS for Template:Para. | .sidebar-outer-title
|
| Template:Para | Additional CSS for Template:Para. | .sidebar-top-image
|
| Template:Para | Additional CSS for Template:Para. | .sidebar-topcaption
|
| Template:Para | Additional CSS for Template:Para. | .sidebar-pretitle or .sidebar-pretitle-with-top-image
|
| Template:Para | Additional CSS for Template:Para. | .sidebar-title or .sidebar-title-with-pretitle
|
| Template:Para | Additional CSS for Template:Para. | .sidebar-image
|
| Template:Para | Additional CSS for Template:Para. | .sidebar-caption
|
| Template:Para | Additional CSS for Template:Para. | .sidebar-above
|
| Template:Para | Additional CSS for section headings. | .sidebar-heading
|
| Template:Para | Additional CSS for Template:Para. | Class assigned to the heading in Template:Para |
| Template:Para | Additional CSS for all section content. | .sidebar-content and/or .sidebar-content-with-subgroup
|
| Template:Para | Additional CSS for Template:Para. | Class assigned to the content in Template:Para |
| Template:Para | Additional CSS for Template:Para. | .sidebar-below
|
| Template:Para | Additional CSS for the generated navbar. | .sidebar-navbar
|
| Template:Para | Additional CSS passed to the navbar module to target the VTE (colors usually). | .sidebar-navbar li, .sidebar-navbar a
|
Tracking category
- Category:Pages using sidebar with the child parameter (2)
- Category:Sidebars with styles needing conversion (27)
See also
- Last pre-Lua version
- {{Sidebar with collapsible lists}}
- {{Infobox}}
- {{Side box}}
- Wikiversity:UBLIST, for help using unbulleted lists within content.