Difference between revisions of "Template:Links to/doc"
imported>NSH002 (Clean up duplicate template arguments using findargdups) |
imported>Cpiral (update) |
||
| Line 3: | Line 3: | ||
{<nowiki/>{Linksto}} finds pages that link to a section. | {<nowiki/>{Linksto}} finds pages that link to a section. | ||
| − | |||
| − | |||
| − | |||
| − | |||
(Note that the input to {{tl|linksto}} is a section, | (Note that the input to {{tl|linksto}} is a section, | ||
while the input to the the search parameter ''linksto'' | while the input to the the search parameter ''linksto'' | ||
| Line 27: | Line 23: | ||
== Usage == | == Usage == | ||
Work from the edit page {{mdash}} going from it and back to it {{mdash}} while finding all links and redirects.<ref> | Work from the edit page {{mdash}} going from it and back to it {{mdash}} while finding all links and redirects.<ref> | ||
| − | It is | + | 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, | (To open a new tab or window instead, | ||
press {{key|Ctrl}} or {{key|Shift}} while following a link.)</ref> | press {{key|Ctrl}} or {{key|Shift}} while following a link.)</ref> | ||
| Line 37: | Line 34: | ||
* {{tag|span|params=id="''inside the double quotes''"}} <kbd>{<nowiki/>{linksto|''span id''}}</kbd> | * {{tag|span|params=id="''inside the double quotes''"}} <kbd>{<nowiki/>{linksto|''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. | + | the markup and spacing ''inside'' the name is important.<ref> |
| + | The actual query, seen on the search results page, | ||
| + | for sections with space characters in them, | ||
| + | replaces every space with a <code>"[ _]"</code>. | ||
| + | This mirrors the behavior of the wikilinks.</ref> | ||
The most common mistake is wrong capitalization. | The most common mistake is wrong capitalization. | ||
| + | If the section of interest is in the Wikipedia or File namespaces, | ||
| + | (or their talk namespaces) rerun {{tl|linksto}} so that aliases are found.<ref> | ||
| + | An upcoming version of this might create the search links for you | ||
| + | that create the namespaces "project" and "wp" when Wikipedia is used, | ||
| + | and "media" and "image" when "file" is used for example.</ref> | ||
| + | <!-- | ||
| + | {| class=wikitable | ||
| + | !Alias | ||
| + | !Namespace | ||
| + | |- | ||
| + | |WP||rowspan=2|Wikipedia | ||
| + | |- | ||
| + | |Project | ||
| + | |- | ||
| + | |WT||rowspan=2|Wikipedia talk | ||
| + | |- | ||
| + | |Project talk | ||
| + | |- | ||
| + | |Image||rowspan=2|File | ||
| + | |- | ||
| + | |Media | ||
| + | |- | ||
| + | |Image talk||rowspan=2|File talk | ||
| + | |- | ||
| + | |Media talk | ||
| + | |} | ||
| + | |||
| + | Media does not have sections, just whole pagenames --> | ||
| + | {| class=wikitable | ||
| + | !Alias | ||
| + | !Namespace | ||
| + | |- | ||
| + | |WP||rowspan=2|Wikipedia | ||
| + | |- | ||
| + | |Project | ||
| + | |- | ||
| + | |WT||rowspan=2|Wikipedia talk | ||
| + | |- | ||
| + | |Project talk | ||
| + | |- | ||
| + | |Image||File | ||
| + | |- | ||
| + | |Image talk||File talk | ||
| + | |} | ||
| + | |||
| + | For a discovered link or redirect to your section, | ||
| + | you must edit that page, even if it is a [[wp:user page|user page]]. | ||
| + | Use an [[Help:edit summary|edit summary]] like "fixing changed section name". | ||
| + | |||
| + | === Links === | ||
'''[[Help:Link#Report links to and from a page|Links]]'''. | '''[[Help:Link#Report links to and from a page|Links]]'''. | ||
| − | Taken altogether, the search links generated by this template will list all ''links'' to a section ''name'' of a page ''name''. | + | Taken altogether, the search links generated by this template |
| + | will list all ''links'' to a section ''name'' of a page ''name''. | ||
| + | It looks in the wikitext, and it aggressively matches what looks like a link. | ||
| + | * '''#Links'''{{middot}}Finds <code>#''section''</code> used in wikilinks (and URL-style links). | ||
| + | * '''§Links'''{{middot}}Finds <code>{<nowiki/>{ [[Template:Section link|Section link]] | ''fullpagename'' | ''section'' }}</code>. (uncommon) | ||
| + | * '''EL1'''{{middot}}Finds <code>canonicalurl:fullpagename section name</code> (rare) | ||
| + | * '''EL2'''{{middot}}Finds <code>fullurl:fullpagename section name</code> (rare) | ||
| + | Advanced: | ||
| + | * '''#SL'''{{middot}}Finds sub-page links <code>[<nowiki/>[../#section]]</code> and <code>[<nowiki/>[/''subpagename''#''section'']]</code> | ||
| + | * '''§SL'''{{middot}}Finds same-page and sub-page <code>{<nowiki/>{section link | ''fullpagename'' | ''section''}}</code> or <code>{<nowiki/>{ section link || section name }}</code>. (The template name is case insensitive). | ||
| + | The SL searches are not necessary in article space, or when subpages are not involved. The searches are non-overlapping except when #SL pound shows the current pagename. | ||
| + | === Redirects === | ||
'''[[wp:redirects|Redirects]]'''. | '''[[wp:redirects|Redirects]]'''. | ||
Use the "Tool" '''[[Help:What links here|What links here]]'''. (Its on every page and every edit page.) | Use the "Tool" '''[[Help:What links here|What links here]]'''. (Its on every page and every edit page.) | ||
| Line 51: | Line 113: | ||
These normally report zero results (or fewer than ten). | These normally report zero results (or fewer than ten). | ||
| − | |||
| − | |||
=== Basic === | === Basic === | ||
| Line 62: | Line 122: | ||
# On an edit page enter a {<nowiki/>{linksto}}. | # On an edit page enter a {<nowiki/>{linksto}}. | ||
| − | # [[wp:preview|{{key|Preview}}]] the edit. A pink box appears with | + | # [[wp:preview|{{key|Preview}}]] the edit. A pink box appears with search links inside. |
| − | # Visit each of them while learning how to proceed. | + | # Visit each of them while learning how to proceed.<ref> |
| + | To get an edit tag for each search result, | ||
| + | add this to your custom javaScript: | ||
| + | <pre> | ||
| + | $( 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>' ); | ||
| + | } ); | ||
| + | } | ||
| + | } ); | ||
| + | </pre> | ||
| + | Until it is an official user preference, the code may be susceptible to malcontents. | ||
| + | </ref> | ||
| + | # Go back to your edit. | ||
# Likewise visit the redirects report. | # Likewise visit the redirects report. | ||
| − | |||
| − | |||
| − | |||
=== Advanced === | === Advanced === | ||
| Line 75: | Line 147: | ||
:{<nowiki/>{ [[Help:Searching/Draft#Linksto|linksto]] | ''section'' | ''[[wp:pgn|fullpagename]]'' | ''[[wp:namespace|namespace]]'' }} | :{<nowiki/>{ [[Help:Searching/Draft#Linksto|linksto]] | ''section'' | ''[[wp:pgn|fullpagename]]'' | ''[[wp:namespace|namespace]]'' }} | ||
| − | Linksto | + | Linksto outputs a single line starting with the fullpagename, and followed by the same, basic set of labels. |
| − | + | This style is fit for collaboration or storage for [[wp:wikiprojects|wikiprojects]]. | |
| − | |||
| − | |||
| − | Just add | + | Just add ''fullpagename'' in parameter two. |
| − | + | Capitalization is not important for the fullpagename | |
| + | unless you will be using the '''#SL''' search link.<ref name=ipad> | ||
| + | Only the '''#SL''' search uses the case-sensitive search parameter "linksto". | ||
| + | Also for ''linksto'' (the search parameter), the first character must be capitalized | ||
| + | even when it is lowercase in the title line. | ||
| + | For example, "[[IPad]]" must be used for '''#SL''' searches, '''not''' [[iPad]].</ref> | ||
To limit search results to a namespace, use parameter three. | To limit search results to a namespace, use parameter three. | ||
| Line 94: | Line 169: | ||
'''1<sup>st</sup>'''{{space|5}} ''[[WP:ANCHORS|Section]]''. Case sensitive. Matches wikitext. | '''1<sup>st</sup>'''{{space|5}} ''[[WP:ANCHORS|Section]]''. Case sensitive. Matches wikitext. | ||
| − | '''2<sup>nd</sup>'''{{space|5}} ''[[WP:pgn|Fullpagename]]''. | + | '''2<sup>nd</sup>'''{{space|5}} ''[[WP:pgn|Fullpagename]]''. Usually not case sensitive<ref name=ipad/> |
| − | '''3<sup>rd</sup>'''{{space|5}} ''[[wp:namespace|namespace]]''. Defaults to all. Accepts aliases. | + | '''3<sup>rd</sup>'''{{space|5}} ''[[wp:namespace|namespace]]''. Defaults to all. Accepts [[wp:ns#Aliases|aliases]]. |
== Examples == | == Examples == | ||
Revision as of 01:15, 13 December 2015
| 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. |
{{Linksto}} finds pages that link to a section. (Note that the input to {{linksto}} is a section, while the input to the the search parameter linksto is a fullpagename.)
Contents
Purpose
Now you can use {{linksto}} to help decide when it is safe change section headings,
and safely remove {{anchor}} templates or <span id=section name>...</span>.
- Manage anchors. Assess and delete excess anchors. Move and replace anchors.
- Manage section headings. Delete section headings. Rename section headings.
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, {{linksto}}, 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, all incoming links to a section can be known.
Usage
Work from the edit page — going from it and back to it — while finding all links and redirects.[1] When entering a {{linksto|section}} copy any section name exactly as it appears in the wikitext:
== inside the heading markup =={{linksto|section heading}} or{{anchor | inside the anchor parameter }}{{linksto|anchor}} or<span id="inside the double quotes">...</span>{{linksto|span id}}
The spacing outside the name is not important, but the markup and spacing inside the name is important.[2] The most common mistake is wrong capitalization.
If the section of interest is in the Wikipedia or File namespaces, (or their talk namespaces) rerun {{linksto}} so that aliases are found.[3]
| Alias | Namespace |
|---|---|
| WP | Wikipedia |
| Project | |
| WT | Wikipedia talk |
| Project talk | |
| Image | File |
| Image talk | File talk |
For a discovered link or redirect to your section, 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 links to a section name of a page name. It looks in the wikitext, and it aggressively matches what looks like a link.
- #Links · Finds
#sectionused in wikilinks (and URL-style links). - §Links · Finds
{{ Section link | fullpagename | section }}. (uncommon) - EL1 · Finds
canonicalurl:fullpagename section name(rare) - EL2 · Finds
fullurl:fullpagename section name(rare)
Advanced:
- #SL · Finds sub-page links
[[../#section]]and[[/subpagename#section]] - §SL · Finds same-page and sub-page
{{section link | fullpagename | section}}or{{ section link || section name }}. (The template name is case insensitive).
The SL searches are not necessary in article space, or when subpages are not involved. The searches are non-overlapping except when #SL pound shows the current pagename.
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
- {{ linksto | section }}
Linksto creates a pink box with search links inside: one to find wikilinks, one to find templates ({{Section link}}), and one to find external-style links.
- On an edit page enter a {{linksto}}.
- 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.
- Likewise visit the redirects report.
Advanced
| 40x40px | Please don't leave a search link in an article. |
- {{ linksto | section | fullpagename }}
- {{ linksto | section | fullpagename | namespace }}
Linksto outputs a single line starting with the fullpagename, and followed by the same, basic set of labels. This style is fit for collaboration or storage for wikiprojects.
Just add fullpagename in parameter two. Capitalization is not important for the fullpagename unless you will be using the #SL search link.[5]
To limit search results to a namespace, use parameter three.
Parameters
Spacing does not matter around the input.
{{ linksto | 1st | 2nd | 3rd }}
1stTemplate:Space Section. Case sensitive. Matches wikitext.
2ndTemplate:Space Fullpagename. Usually not case sensitive[5]
3rdTemplate:Space namespace. Defaults to all. Accepts aliases.
Examples
| What you type | What you get | Description | |
|---|---|---|---|
| {{ linksto | Examples }} |
This is /doc. Go up to test this. |
Find all links to this section. | |
| {{ linksto | Usage }} |
This is /doc. Go up to test this. |
Find all links to this page's Usage section. |
What you type:
{{ linksto | Registers | Javanese language }}
{{ linksto | Different functions of "to be" | E-prime }}
What you get:
Javanese language#Registers: Template:Plain link · Template:Plain link
E-prime#Different functions of "to be": Template:Plain link · Template:Plain link
Namespace filtering.
What you type:
{{ linksto | Projects | Mediawiki | talk }}
{{ linksto | Projects | Mediawiki | user talk }}
What you get:
Mediawiki#Projects: Template:Plain link · Template:Plain link
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:
{{ linksto | Wikipedia:Manual of Style | Section headings | user talk }}
{{ linksto | Wikipedia:Manual of Style | Section management | user talk }}
{{ linksto | 3=Wikipedia:Manual of Style | 2=Section headings | 1=user talk }}
{{ linksto | 3=Wikipedia:Manual of Style | 2=Section management | 1=user talk }}
What you get:
Section headings#user talk: Template:Plain link · Template:Plain link
Section management#user talk: Template:Plain link · Template:Plain link
See also
- Help:Linking#Report links to and from a page
- Template:linksearch (talk⧼dot-separator⧽links⧼dot-separator⧽edit) finds external links
- category:search templates
Notes and references
- ↑ 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. - ↑ An upcoming version of this might create the search links for you that create the namespaces "project" and "wp" when Wikipedia is used, and "media" and "image" when "file" is used for example.
- ↑
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 Only the #SL search uses the case-sensitive search parameter "linksto". Also for linksto (the search parameter), the first character must be capitalized even when it is lowercase in the title line. For example, "IPad" must be used for #SL searches, not iPad.