Difference between revisions of "Template:Links to/doc"
imported>Cpiral (→See also: fix a link, improve last bullet) |
imported>DB1729 (Reverted 3 edits by Bunlert2543 (talk): Unexplained removal of content) |
||
| (6 intermediate revisions by 3 users not shown) | |||
| Line 2: | Line 2: | ||
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --> | <!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --> | ||
| − | {{tl| | + | {{tl|Links to}} lists all pages that link to a section, |
and shows a snippet from each page, with the link highlighted. | and shows a snippet from each page, with the link highlighted. | ||
It uses the linksto search parameter to find the pages, | It uses the linksto search parameter to find the pages, | ||
and from that a regexp search to find the section's incoming links. | and from that a regexp search to find the section's incoming links. | ||
| − | (Note that the input to {{tl| | + | (Note that the input to {{tl|links to}} is a section, |
while the input to the search parameter ''linksto'' | while the input to the search parameter ''linksto'' | ||
is a [[wp:pgn|fullpagename]].) | is a [[wp:pgn|fullpagename]].) | ||
| Line 12: | Line 12: | ||
== Purpose == | == Purpose == | ||
| − | Use {{tl| | + | Use {{tl|links to}} to help decide about changing or removing [[MOS:HEADINGS|section headings]], |
{{tl|anchor}}s, or "span id=" (HTML) tags. | {{tl|anchor}}s, or "span id=" (HTML) tags. | ||
* Manage anchors. Assess and delete excess anchors. Move and replace anchors. | * Manage anchors. Assess and delete excess anchors. Move and replace anchors. | ||
| Line 34: | Line 34: | ||
But [[MOS:HEADINGS|it might break a link]]. And you're not sure about adding {{tl|anchors}}. | But [[MOS:HEADINGS|it might break a link]]. And you're not sure about adding {{tl|anchors}}. | ||
* "'''[[Help:What links here|What links here]]'''" does not report links by ''section name''. | * "'''[[Help:What links here|What links here]]'''" does not report links by ''section name''. | ||
| − | * This template, {{tl| | + | * This template, {{tl|links to}}, reports sections but does not report ''redirects''. |
* "'''Show redirects only'''" ''does'' report redirects to sections names. (It's on the '''What links here''' page). | * "'''Show redirects only'''" ''does'' report redirects to sections names. (It's on the '''What links here''' page). | ||
Using these three tools, the incoming wikilinks to a section can be known.<ref name=notfound/> | Using these three tools, the incoming wikilinks to a section can be known.<ref name=notfound/> | ||
| Line 45: | Line 45: | ||
It is safe also to activate a search link, for the same reasons. | It is safe also to activate a search link, for the same reasons. | ||
(To open a new tab or window instead, | (To open a new tab or window instead, | ||
| − | press {{key|Ctrl}} or {{key|Shift}} while following a link.)</ref> | + | press {{key press|Ctrl}} or {{key press|Shift}} while following a link.)</ref> |
| − | When entering a <kbd>{<nowiki/>{ | + | When entering a <kbd>{<nowiki/>{links to{{!}}''section''}}</kbd> |
copy any [[WP:ANCHOR|section name]] exactly as it appears in the wikitext: | copy any [[WP:ANCHOR|section name]] exactly as it appears in the wikitext: | ||
| − | * <code>== ''inside the heading markup'' ==</code> <kbd>{<nowiki/>{ | + | * <code>== ''inside the heading markup'' ==</code> <kbd>{<nowiki/>{links to|''section heading''}}</kbd> or |
| − | * <code>{<nowiki/>{anchor | ''inside the anchor parameter'' }}</code> <kbd>{<nowiki/>{ | + | * <code>{<nowiki/>{anchor | ''inside the anchor parameter'' }}</code> <kbd>{<nowiki/>{links to|''anchor''}}</kbd> or |
| − | * {{tag|span|params=id="''inside the double quotes''"}} <kbd>{<nowiki/>{ | + | * {{tag|span|params=id="''inside the double quotes''"}} <kbd>{<nowiki/>{links to|''span id''}}</kbd> |
The spacing ''outside'' the name is not important, but | The spacing ''outside'' the name is not important, but | ||
the markup and spacing ''inside'' the name is important.<ref> | the markup and spacing ''inside'' the name is important.<ref> | ||
| Line 85: | Line 85: | ||
=== Basic === | === Basic === | ||
| − | :{<nowiki/>{ [[Help:Searching | + | :{<nowiki/>{ [[Help:Searching#linksto:|links to]] | ''section'' }} |
| − | + | Links to creates a pink box with search links inside: | |
one to find wikilinks, one to find templates ({{tl|Section link}}). | one to find wikilinks, one to find templates ({{tl|Section link}}). | ||
| − | # On an edit page enter a {<nowiki/>{ | + | # On an edit page enter a {<nowiki/>{links to}}. |
| − | # [[wp:preview|{{key|Preview}}]] the edit. A pink box appears with search links inside. | + | # [[wp:preview|{{key press|Preview}}]] the edit. A pink box appears with search links inside. |
# Visit each of them while learning how to proceed.<ref> | # Visit each of them while learning how to proceed.<ref> | ||
To get an edit tag for each search result, | To get an edit tag for each search result, | ||
| Line 113: | Line 113: | ||
=== Advanced === | === Advanced === | ||
| − | :{<nowiki/>{ [[Help:Searching | + | :{<nowiki/>{ [[Help:Searching#linksto:|links to]] | ''section'' | ''[[wp:pgn|fullpagename]]'' }} |
| − | :{<nowiki/>{ [[Help:Searching | + | :{<nowiki/>{ [[Help:Searching#linksto:|links to]] | ''section'' | ''[[wp:pgn|fullpagename]]'' | ''[[wp:namespace|namespace]]'' }} |
| − | + | Links to outputs a single line starting with the fullpagename, and followed by the search links. | |
This style is fit for collaboration or storage for [[wp:wikiprojects|wikiprojects]]. | This style is fit for collaboration or storage for [[wp:wikiprojects|wikiprojects]]. | ||
| Line 136: | Line 136: | ||
Spacing does not matter ''around'' the input. | Spacing does not matter ''around'' the input. | ||
| − | {<nowiki/>{ | + | {<nowiki/>{ links to | '''1<sup>st</sup>''' | '''2<sup>nd</sup>''' | '''3<sup>rd</sup>''' }} |
'''1<sup>st</sup>'''{{space|5}} ''[[WP:ANCHORS|Section]]''. Case sensitive. Matches wikitext character-wise. | '''1<sup>st</sup>'''{{space|5}} ''[[WP:ANCHORS|Section]]''. Case sensitive. Matches wikitext character-wise. | ||
| Line 147: | Line 147: | ||
<!-- | <!-- | ||
1) The wikilink [[../|Go up]] below is | 1) The wikilink [[../|Go up]] below is | ||
| − | so that template | + | so that template links to finds this subpage search-links to it. |
| − | The examples only work from ../Template: | + | The examples only work from ../Template:Links to, see? |
2) Also for the search-insourse regexp part, we need: #Usage#Examples. | 2) Also for the search-insourse regexp part, we need: #Usage#Examples. | ||
(See the testcases for an alternative explanation of these two workings.) | (See the testcases for an alternative explanation of these two workings.) | ||
| Line 160: | Line 160: | ||
!Description | !Description | ||
|- | |- | ||
| − | |style=white-space:nowrap|<nowiki>{{ | + | |style=white-space:nowrap|<nowiki>{{ links to | Examples }}</nowiki> |
| − | |{{ | + | |{{ links to | Examples }} |
<noinclude>This is /{{SUBPAGENAME}}. [[../|Go up]] to test this.</noinclude> | <noinclude>This is /{{SUBPAGENAME}}. [[../|Go up]] to test this.</noinclude> | ||
|Find all links to this section. | |Find all links to this section. | ||
|- | |- | ||
| − | |<nowiki>{{ | + | |<nowiki>{{ links to | Usage }}</nowiki> |
| − | |{{ | + | |{{ links to | Usage }} |
<noinclude>This is /{{SUBPAGENAME}}. [[../|Go up]] to test this.</noinclude> | <noinclude>This is /{{SUBPAGENAME}}. [[../|Go up]] to test this.</noinclude> | ||
|Find all links to this page's Usage section. | |Find all links to this page's Usage section. | ||
| Line 175: | Line 175: | ||
! '''What you get:''' | ! '''What you get:''' | ||
|- | |- | ||
| − | ||<kbd>{<nowiki/>{ | + | ||<kbd>{<nowiki/>{ links to | Linux | Operating system }}</kbd> |
| − | |{{ | + | |{{ links to | Linux | Operating system }} |
|- | |- | ||
| − | ||<kbd>{<nowiki/>{ | + | ||<kbd>{<nowiki/>{ links to | Registers | Javanese language }}</kbd> |
| − | |{{ | + | |{{links to | Registers | Javanese language }} |
|- | |- | ||
| − | ||<kbd>{<nowiki/>{ | + | ||<kbd>{<nowiki/>{ links to | Different functions of "to be" | E-prime }}</kbd> |
| − | |{{ | + | |{{links to | Different functions of "to be" | E-prime }} |
|- | |- | ||
| − | ||<kbd>{<nowiki/>{ | + | ||<kbd>{<nowiki/>{ links to | Projects | Mediawiki | <mark>talk</mark> }}</kbd> |
| − | |{{ | + | |{{ links to | Projects | Mediawiki | talk }} |
|- | |- | ||
| − | ||<kbd>{<nowiki/>{ | + | ||<kbd>{<nowiki/>{ links to | Projects | Mediawiki | user talk }}</kbd> |
| − | |{{ | + | |{{ links to | Projects | Mediawiki | user talk }} |
|} | |} | ||
| Line 194: | Line 194: | ||
Reordering. If you used ''natural'' instead of ''most-requested'' order, you can number them. | Reordering. If you used ''natural'' instead of ''most-requested'' order, you can number them. | ||
'''What you type:'''<s><kbd><nowiki> | '''What you type:'''<s><kbd><nowiki> | ||
| − | {{ | + | {{ links to | Wikipedia:Manual of Style | Section headings }} |
| − | {{ | + | {{ links to | WP | Wikipedia:Manual of Style | Section management }}</nowiki></kbd></s><kbd><nowiki> |
| − | {{ | + | {{ links to | 2= Wikipedia:Manual of Style | 1=Section headings }} |
| − | {{ | + | {{ links to | 3= WP | 2= Wikipedia:Manual of Style | 1= Section management }}</nowiki></kbd> |
'''What you get:''' | '''What you get:''' | ||
| − | {{ | + | {{ links to | 2=Wikipedia:Manual of Style | 1=Section headings }} |
| − | {{ | + | {{ links to | 2=Wikipedia:Manual of Style | 1=Block quotations | 3= WP }} |
</poem> | </poem> | ||
| Line 215: | Line 215: | ||
== Notes and references == | == Notes and references == | ||
{{reflist}} | {{reflist}} | ||
| − | <includeonly>{{ | + | <includeonly>{{Sandbox other|| |
<!-- Categories below this line, please; interwikis at Wikidata --> | <!-- Categories below this line, please; interwikis at Wikidata --> | ||
<!-- Includeonly tags put content onto the page that transcludes this page. | <!-- Includeonly tags put content onto the page that transcludes this page. | ||
Latest revision as of 11:04, 16 December 2020
| 40px | This is a documentation subpage for Template:Links to. It contains usage information, categories and other content that is not part of the original template page. |
{{Links to}} lists all pages that link to a section, and shows a snippet from each page, with the link highlighted. It uses the linksto search parameter to find the pages, and from that a regexp search to find the section's incoming links. (Note that the input to {{links to}} is a section, while the input to the search parameter linksto is a fullpagename.)
Contents
Purpose
Use {{links to}} to help decide about changing or removing section headings, {{anchor}}s, or "span id=" (HTML) tags.
- Manage anchors. Assess and delete excess anchors. Move and replace anchors.
- Manage section headings. Delete section headings. Rename section headings.
This template lists all the wikilinks to a section that are found in the wikitext as:
- [[ fullpagename#section ]]
- {{ section link | section}}
- {{ slink|section}}
These are all the usual-style wikilinks, and the search links produced by this template are definitive concerning the sections of most pages.[1]
While editing a section, you decide to rename its heading. Or you want to restructure an article. But it might break a link. And you're not sure about adding {{anchors}}.
- "What links here" does not report links by section name.
- This template, {{links to}}, reports sections but does not report redirects.
- "Show redirects only" does report redirects to sections names. (It's on the What links here page).
Using these three tools, the incoming wikilinks to a section can be known.[1]
Usage
Work from the edit page — going from it and back to it — while finding all links and redirects.[2] When entering a {{links to|section}} copy any section name exactly as it appears in the wikitext:
== inside the heading markup =={{links to|section heading}} or{{anchor | inside the anchor parameter }}{{links to|anchor}} or<span id="inside the double quotes">...</span>{{links to|span id}}
The spacing outside the name is not important, but the markup and spacing inside the name is important.[3] The most common mistake is wrong capitalization.
Should you change or removed a section name, then for each incoming wikilink or redirect it had, you must edit that page, even if it is a user page. Use an edit summary like "fixing changed section name".
Links
Links. Taken altogether, the search links generated by this template will list all wikilinks to a section name of a page name.
- #Links · Finds
#sectionused in wikilinks (and URL-style links). - §Links · Finds
{{ Section link | fullpagename | section }}. (uncommon)
The results do not overlap and are guaranteed links to that section.
Redirects
Redirects. Use the "Tool" What links here. (Its on every page and every edit page.) Once there, immediately activate the "external tool" Show redirects only. If your section name is shown, your redirects are reported. Just find the wikilinks to them using What links here, and you're done. If your section is not shown in the report, no redirect at all links to your section.
These normally report zero results (or fewer than ten).
Basic
- {{ links to | section }}
Links to creates a pink box with search links inside: one to find wikilinks, one to find templates ({{Section link}}).
- On an edit page enter a {{links to}}.
- Preview the edit. A pink box appears with search links inside.
- Visit each of them while learning how to proceed.[4]
- Go back to your edit page.
- Visit the redirects report.
- Go back to your edit page and proceed.
Advanced
- {{ links to | section | fullpagename }}
- {{ links to | section | fullpagename | namespace }}
Links to outputs a single line starting with the fullpagename, and followed by the search links. This style is fit for collaboration or storage for wikiprojects.
Just add the fullpagename of the page of interest in parameter two. (The {{FULLPAGENAME}}, before {{DISPLAYTITLE}} or the like may have applied.)[5]
To limit search results to a namespace instead of all namespaces, use parameter three. This is necessary for a highly linked-to page like the Manual of Style (over a million links to it). This is useful to try when a search takes around twenty seconds and returns with zero results. (Search silently fails, with no indication of an HTML timeout.)
Parameters
Spacing does not matter around the input.
{{ links to | 1st | 2nd | 3rd }}
1stTemplate:Space Section. Case sensitive. Matches wikitext character-wise.
2ndTemplate:Space Fullpagename. Case sensitive. First letter capitalized.[5]
3rdTemplate:Space namespace. Defaults to all. Accepts aliases.
Examples
| What you type | What you get | Description | |
|---|---|---|---|
| {{ links to | Examples }} |
This is /doc. Go up to test this. |
Find all links to this section. | |
| {{ links to | Usage }} |
This is /doc. Go up to test this. |
Find all links to this page's Usage section. |
| What you type: | What you get: |
|---|---|
| {{ links to | Linux | Operating system }} | Operating system#Linux: Template:Plain link · Template:Plain link |
| {{ links to | Registers | Javanese language }} | Javanese language#Registers: Template:Plain link · Template:Plain link |
| {{ links to | Different functions of "to be" | E-prime }} | E-prime#Different functions of "to be": Template:Plain link · Template:Plain link |
| {{ links to | Projects | Mediawiki | talk }} | Mediawiki#Projects: Template:Plain link · Template:Plain link |
| {{ links to | Projects | Mediawiki | user talk }} | Mediawiki#Projects: Template:Plain link · Template:Plain link |
Reordering. If you used natural instead of most-requested order, you can number them.
What you type:
{{ links to | Wikipedia:Manual of Style | Section headings }}
{{ links to | WP | Wikipedia:Manual of Style | Section management }}
{{ links to | 2= Wikipedia:Manual of Style | 1=Section headings }}
{{ links to | 3= WP | 2= Wikipedia:Manual of Style | 1= Section management }}
What you get:
Wikipedia:Manual of Style#Section headings: Template:Plain link · Template:Plain link
Wikipedia:Manual of Style#Block quotations: Template:Plain link · Template:Plain link
See also
- Help:Linking#Link reports
- Template:linksearch (talk⧼dot-separator⧽links⧼dot-separator⧽edit) the edit link shows the code
- mw:Help:Linksearch#Linksearch and sections
- T121379 about finding external links
- . Previous versions searched for external links to sections.
Notes and references
- ↑ 1.0 1.1
There may exist additional wikilinks (internal links) to a given section.
These are not currently listed:
- Web links made with URL-style syntax.
- wikilinks or {{Section link}}'s placed on a page by a transclusion.
- ↑ It is safe to navigate away from an edit page, for example to test a wikilink in the preview. It is safe also to activate a search link, for the same reasons. (To open a new tab or window instead, press Ctrl or ⇧ Shift while following a link.)
- ↑
The actual query, seen on the search results page,
for sections with space characters in them,
replaces every space with a
"[ _]". This mirrors the behavior of the wikilinks. - ↑
To get an edit tag for each search result,
add this to your custom javaScript:
$( function() { 'use strict'; if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' ) { $( '.mw-search-result-heading a' ).each( function() { $( this ).after( '<span class="searchedit">[<a href="' + $( this ).attr( 'href' ) + '?action=edit">edit</a>]</span>' ); } ); } } );Until it is an official user preference, the code may be susceptible to malcontents.
- ↑ 5.0 5.1 It's the canonical name, not the redirect. It's the title line exactly, but the title line should begin with a capital letter. If there are any questionable aspects to the title's appearance, go to that page and render {{FULLPAGENAME}} in a temporary preview.