User:Adamw/Delete: Category alias proposal

This page describes some potential technical implementations for category aliasing.

Problem statement
In some cases it's necessary to render category labels differently depending on the subject of an article. For example, in German Wikipedia any article about an Ärztin (woman doctor) displays category "Arzt" which is marginally grammatical and can be improved by using the correctly gendered title. Incorrect category labels using the generic masculine also diminish the visibility of women in many fields.

Current work
A 2017 survey of German Wikipedians identified this as a priority to fix. The Wikimedia Deutschland Technical Wishes team is hoping to solve this problem in 2020, with a technical mechanism to allow for category aliasing. Aliases will have specific behaviors still to be discussed, but the general idea is that an aliased category label will appear in the list of categories at the bottom of an article, but canonically indexed under another category. A made-up English equivalent would be that a biographical article about a

Soft redirect categories
Categories are only ever soft-redirected to one another. In English Wikipedia, this is accomplished with the  template, which has semantics like HTTP's "301 Moved permanently", and is helpful for common typos such as "Category:Stub" when "Category:Stubs" was intended. A soft-redirected category should never be used on an article, but when this does happen a bot can fix the article to use the target category instead. Soft-redirect category pages themselves remain indefinitely, or until they are no longer needed.

Hard redirects are broken
At first glance there should be two ways to redirect a category, like any other wiki page: either with a soft redirect template or by the hard-redirect " " directive in wikitext. Unfortunately, a hard redirect is never correct and a bot will convert the hard redirect category to a soft redirect. This is "because of the software's inability to recategorize pages from redirected categories". An article page using the redirect category will be a member of the alias but not the target category, so nothing is gained by using the redirect. At the same time, visiting the alias category page results in a browser redirect to the target category (unless the magical  was included), which does not include the article. This is a bad user experience.

Existing bots will rewrite any hard redirected categories as a templated soft redirect, using the "Category redirect" template, for example with this edit.

Proposal
We can change the behavior of hard-redirected category pages, so that the linking article is categorized under the redirect target category. If an article is categorized with, and the "Category:Firewoman" page contains the source " ", then the biographical article will display the "Firewoman" category, but will show up on the "Category:Firefighter" page.

An optional extra behavior would be that the article also shows up on the "Category:Firewoman" redirect page since this will be helpful for finding all members of an alias, but this is a UX question, because the hard redirect also means that it will take an extra URL parameter to reach the Firewoman category page.

Prior work
A similar idea for category redirects has been around since at least 2009, when a similar feature was temporarily deployed. The implementation was incomplete and quickly reverted, but onwiki discussion was generally positive, and focused on fixing the edge cases rather than reaching consensus to disable. The revert was for technical reasons, the feature had not been completely specified and the code was no more than a proof of concept.

Alias keyword
Rather than change the behavior of " ", we might introduce a new directive such as " " instead. Although this is nice because it gives us additional freedom to add constraints and behaviors, it means a wikitext syntax change, which could confuse parsers, etc.

Non-page representations
It might be possible to implement category aliases in some other way which doesn't involve the creation of a category page for the alias. For example, category links could accept parameters a la the  tag, or the main category page could include information that is used to track and apply aliases.

So far, any representations of category aliases which don't include a full category page for the alias seem to quickly multiply our technical debt. We'll have to modify the many places where MediaWiki code interacts with categories, e.g. making the aliases available in search and autocomplete features.