Open main menu
This documentation is transcluded from Template:Pg/doc.

Render localized link to Commons/Help page name


{{pg |1= |2= |anchor= }}


Renders a link to a version of a target page in the Commons or Help namespace in the most suitable language that is available.

Target page selection

If the user is viewing a page in a language other than English and selects a link, they will be taken to a version of the target page in the same language if available, failing that in their preference language, and failing that in English.

  • If the current page language is English, {{pg|pagename}} renders [[pagename]]
  • If the current page language is e.g. French and there is a French version of the target page, renders e.g. [[pagename/fr|pagename]]
  • Otherwise renders e.g. [[Special:MyLanguage/pagename|pagename]]
    This will link to a version of the target page in the user's preferred language if available, or in English otherwise.

Display name

A display name will be used if provided. So {{pg|pagename|displayname}} renders e.g.

[[pagename|displayname]] or
[[pagename/fr|displayname]] or

If no display name is provided and the link is to a non-English page, the translated title of that page will be used if available. E.g., on a Spanish language page,

{{pg|Commons:Copyright rules by territory/Argentina}} renders
[[Commons:Copyright rules by territory/Argentina/es|Commons:Reglas de derechos de autor por territorio/Argentina]]


A link to an anchor or section within a Commons or Help target page should be coded as {{pg|pagename|anchor=ABC}}, where ABC is the name of the anchor or section. The name of a section usually varies from one language to another, and may be changed. A link to a short capitalized {{Anchor}} on the target page will be more stable. The anchor can be placed outside the translatable part of the page to ensure that it is the same for all language versions, for example on Commons:File types as:

===Unsupported file types===

A link to this anchor on a Spanish language page could be coded as:

{{pg|Commons:File types|anchor=UNSUPP|Tipos de archivo no soportados}}

which would render:

[[Commons:File types/es#UNSUPP|Tipos de archivo no soportados]]

If there was no Spanish version of the target page, it would render:

[[Special:MyLanguage/Commons:File types#UNSUPP|Tipos de archivo no soportados]]

Template parameters

1Target page namenonerequired
2Display namenoneoptional
anchorName of anchor (or section) in the target pagenoneoptional

Additional information

The template is intended to be used in the following namespaces: the Commons namespace

The template is intended to be used by the following user groups: all users

Relies on:

  • {{Pg/target}} Contains the core logic
  • {{Pg2}} For pages that are not in the Commons or Help namespaces. Links to a page in the user's preferred language if available.

See also

When a user is browsing through Commons or Help documentation, {{Pg}} tries to keep them on pages in their current selection of language as long as possible, falling back if needed to their preferred language and then to English. Thus a user who prefers a poorly supported language such as Asturian may choose to browse documentation in Spanish. {{Pg}} will link them from page to page in Spanish, while {{Localized link}} would repeatedly try to link to an Asturian version, fail, and fall back to English.

On the other hand, when a user is looking at a file description, they will see it in their preferred language if available, or English otherwise, because file descriptions and license templates are typically localized to preferred language using {{int:}}, {{De}}, {{PD-old-70}} etc. When the user clicks on a link in the file description it makes sense to take them to a target page in their preferred language if available, or English otherwise.


This template is not intended to be localized.