Support shorthand for themes/plugins/presets configuration
See original GitHub issueHave you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Description
When configuring a theme, plugin, or preset, instead of looking up for the NPM package itself, we could have a chain of NPM package resolve attempts, in the respective order/priority:
docusaurus-theme-{theme}@docusaurus/theme-{theme}@{theme}/docusaurus-theme{theme}
The same for plugins and presets.
Example docusaurus configuration:
module.exports = {
themes: ['classic'],
};
Package resolve attempts:
docusaurus-theme-classic@docusaurus/theme-classic@classic/docusaurus-themeclassic
PS.: it is not clear to me if we should lookup for scoped packages only when the user input begins with @, so there are two alternatives:
A: themes: ['@org'] -> @org/docusaurus-theme (resolvers chain, as of the numbered list above: 3)
B: themes: ['org'] -> @org/docusaurus-theme (resolvers chain, as of the numbered list above: 1, 2, 3, 4)
Has this been requested on Canny?
https://docusaurus.io/feature-requests/p/shorthand-for-themespluginspresets-configuration
Motivation
Some modern tools are adopting the “shareable config” concept, generally supporting shorthand, so the user may omit the keywords that may be inferred, e.g. eslint-config-{config}, eslint-plugin-{plugin}.
This also encourages developers to publish their packages in a canonical way (including docusaurus-(theme|plugin|preset) in the name), so a GitHub or NPM search would result in way more packages, therefore increasing their reusability and popularity.
Reference: https://eslint.org/docs/developer-guide/shareable-configs
API design
I guess the API design is pretty straightforward: users may omit the following keywords in their configuration:
docusaurus-themedocusaurus-plugindocusaurus-preset
About the implementation itself, we could use ESLint as the baseline: https://github.com/eslint/eslintrc/blob/main/lib/shared/naming.js#L14
Or thinking in a more ambitious way, we could have a dedicated package/repository to that, just like cosmiconfig, which does the same, but for configuration file names lookup.
Have you tried building it?
No response
Self-service
- I’d be willing to contribute this feature to Docusaurus myself.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (4 by maintainers)

Top Related StackOverflow Question
That’s worth doing a POC, see how complex it would be to support and apply to our own config file 👍
I’d rather not introduce too many fallback patterns but rather only a few ones so that the naming convention the community uses is consistent and there’s not much possible naming choices if you want shorthand to work
@fsmaia I’m personally in favor of this but let’s hear from @slorber as well. Three things I’m not sure of though:
@docusaurus/theme-{theme}beforedocusaurus-theme-{theme}since the former is the convention of official Docusaurus packages?docusaurus-{theme}(without thetheme-prefix) because it also seems to be widely used?@{theme}/docusaurus-themeone. It’s not a widely used pattern in the wild and it… doesn’t make much sense to me