Repository navigation
Docusaurus tutorial
The Docusaurus tutorial is very important: it is the very first thing a Docusaurus user sees (init template or CodeSandbox)
Please report here if anything does not work or is unclear.
All reactions
Replies: 15 comments 46 replies
To be honest, I've been having a lousy time trying to figure out to get http://localhost:3000 working on my Mac. How necessary is activating a local web server for this tutorial and for Docusaurus as a whole? If it's absolutely essential, can that step be added to the list of requirements alongside Node and Yarn?
All reactions
You don't need a local web server at all, just nodejs > 12 + yarn/npm.
Running yarn build && yarn serve should be enough to have a production build running locally.
Docusaurus ships with an embedded very simple web server (yarn serve).
Can you explain what you struggle with?
Can you share error messages or whatever?
What specific parts of the tutorial are hard to understand?
Have you tried the online playgrounds?
All reactions
You don't need a local web server at all, just nodejs > 12 + yarn/npm.
Ah, okay. Unfortunately, http://localhost:3000 still comes up as a blank webpage no matter which browser I use (Firefox, Chrome, Safari). It's loading something—here's the HTML I'm seeing:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Docusaurus">
<title>My Site</title>
<link rel="alternate" type="application/rss+xml" href="/blog/rss.xml" title="My Site Blog RSS Feed">
<link rel="alternate" type="application/atom+xml" href="/blog/atom.xml" title="My Site Blog Atom Feed">
<script defer src="/runtime~main.js"></script><script defer src="/main.js"></script><link href="/styles.css" rel="stylesheet">
</head>
<body>
<script>
(function() {
var defaultMode = 'light';
var respectPrefersColorScheme = false;
function setDataThemeAttribute(theme) {
document.documentElement.setAttribute('data-theme', theme);
}
function getStoredTheme() {
var theme = null;
try {
theme = localStorage.getItem('theme');
} catch (err) {}
return theme;
}
var storedTheme = getStoredTheme();
if (storedTheme !== null) {
setDataThemeAttribute(storedTheme);
} else {
if (
respectPrefersColorScheme &&
window.matchMedia('(prefers-color-scheme: dark)').matches
) {
setDataThemeAttribute('dark');
} else if (
respectPrefersColorScheme &&
window.matchMedia('(prefers-color-scheme: light)').matches
) {
setDataThemeAttribute('light');
} else {
setDataThemeAttribute(defaultMode === 'dark' ? 'dark' : 'light');
}
}
})();
</script>
<div id="__docusaurus"></div>
</body>
</html>
I'm able to get the playgrounds to work, but my goal is to create a custom documentation site in GitHub pages that I'm able to edit from my local system.
In all fairness to the tutorial, it is extremely straightforward and every command generates exactly what it's supposed to. I'm also an absolute beginner to this level of technical work. I'm just not able to get a locally hosted Docusaurus file/folder to work on my browser and I'm not sure where I'm going wrong.
I'm going to try to go through the tutorial one more time, this time using my /Sites folder. I'll let you know what specific bugs/error messages come up, if any. Should I open a new issue for this (so I'm not cluttering up this discussion section)?
All reactions
This time, it worked! Not a perfect test since I changed two conditions:
- turning on my localhost using Apache
- making the Docusaurus project in my Sites folder.
I can do further testing about which factor made the difference here, especially since, in theory, neither should not have affected the Docusaurus local web server at all.
All reactions
Update: I'm absolutely a newbie and extremely embarrassed.
Turns out you have to keep the shell running the yarn start command open in order to have an active server. I was exiting the shell because it was like an off-on switch, and the fact that it wasn't returning to the command line made me think it was buggy.
My apologies. Thanks for replying so quickly.
All reactions
-
👍 1 -
😄 1
I see :D thanks for the explanations
Yes, you have to keep the shell open when in dev mode. Errors will be printed where as you edit your docs or site config.
All reactions
I just ran the command
npx @docusaurus/init@latest init my-website classic
to start my Docusaurus project and after running
yarn run start
two of the links on http://localhost:3000/docs/tutorial-basics/congratulations are already broken. I did not change the code at all. Is this a known problem? Pictures are attached and I am quite confused.
links_broken
first_link
second_link
All reactions
I can reproduce on MacOS too, will be fixed soon!
All reactions
this will be solved in #5270, thanks!
All reactions
-
👍 1
please let me know if you have a bug with the canary release: https://docusaurus.io/community/canary
All reactions
@slorber
I have confirmed that the canary release does not have bugs. Here are my testing commands:
cd "C:\Documents (no sync)\Scripts" conda activate docs npx @docusaurus/init@canary init test-docusauraus-2 classic cd test-docusauraus-2 yarn start
Thank you!
All reactions
great, thanks for the feedback ;)
All reactions
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
The tutorial is amazing and quick! One thing I noticed is that when I tried the versioning portion of the tutorial, I saw this error message on the docs page after I ran npm run docusaurus docs:version 1.0:
Uncaught TypeError: Cannot destructure property 'description' of 'metadata' as it is undefined.
Here's a Loom which walks through the issue.
All reactions
Thanks for the feedback @juliannaroen and thanks for creating a video
The tutorial says:
But you did:
This does not look the same to me 🤪 how can we make this clearer?
But I'm still surprised you get this runtime error though.
Have you tried restarting the docusaurus dev server after creating the version?
I'm not sure we support keep the dev server enabled while you run the versioning command in another terminal for example, maybe it's what you tried?
All reactions
Final step "Build your site"
image
(base) paul@paulpauldeMacBook-Pro my-website % npm run build
my-website@0.0.0 build
docusaurus build
[INFO] [en] Creating an optimized production build...
✔ Client
✖ Server
Compiled with some errors in 21.03s
[ERROR] Docusaurus server-side rendering could not render static page with path /foo/bar/bar.
Error: Minified React error #130; visit https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=object&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
[ERROR] Unable to build website for locale en.
[ERROR] Error: Failed to compile with errors.
(base) paul@paulpauldeMacBook-Pro my-website %
All reactions
@Chainguys please show us the content of your page /foo/bar/bar, it's likely you have an error in your code there. It does not seem related to our tutorial because we never ask you to create a page at /foo/bar/bar afaik
All reactions
@slorber Mentioned here: https://github.com/facebook/docusaurus/blob/main/packages/create-docusaurus/templates/shared/docs/tutorial-basics/create-a-page.md
With no prior knowledge in React or even coding in general, they assumed you just need to create an empty file with no content.
All reactions
ah ok 😅 so not sure how we can improve this 🤪 maybe move the routing rules/mapping/examples at the end? 🤷♂️
All reactions
The tutorial cannot be edited. If I click the Edit button, it reports 404.
image
All reactions
Oh, that site is terribly outdated. cc @slorber We need to update it.
The best way to explore it is via CodeSandbox or setting it up locally.
All reactions
Oh, got it. Thanks for the heads-up.
I'm a newcomer. Not sure what CodeSandbox is, but I think I'll find out.
Setting it up locally feels cumbersome anyway.
All reactions
You can follow the guide here: https://docusaurus.io/docs/installation
All reactions
OK. Thank you!
All reactions
Ah thanks :D didn't notice but the Netlify deployment is failing
https://app.netlify.com/sites/docusaurus-tutorial
5:20:57 PM: error docusaurus@0.0.0: The engine "node" is incompatible with this module. Expected version ">=16.14". Got "12.18.0"
It's fixed now
All reactions
-
🎉 1
Hello, great tutorial 🙌
Little feedback on the configure-the-sidebar part of the basic tutorial.
When editing the sidebars.js file as stated in the doc, I don't have a sidebar anymore on my website.
Editing the tutorialSidebar object:
Screenshot 2022年09月01日 at 10 57 03
Or even copy / pasting the exact code from the doc (everything else from the original file is commented out)
Screenshot 2022年09月01日 at 10 57 21
No sidebar anymore.
Screenshot 2022年09月01日 at 10 59 41
I would assume I am supposed to see a sidebar.
It would be great also to add some information about what we are supposed to see / what is supposed to happen when we update this sidebars.js to create it explicitly.
All reactions
Thanks for the feedback, I see how it can be confusing
The sidebar is only displayed on docs it contains:
- the sidebar is displayed on the "hello" doc
- the sidebar isn't displayed on the "create-a-document" doc because it doesn't contain that doc
I'll update the tutorial to make sure following these instructions from the current page would still display the sidebar. Solution:
tutorialSidebar: [ { type: 'category', label: 'Tutorial', items: ['create-a-document', 'hello'], }, ],
Will be handled in #8032
All reactions
Ok I see how this works now, thanks for the answer
All reactions
-
👍 1
No mention of site config / themeConfig
Our tutorial doesn't currently show some basic things such as explaining the site config file, and in particular themeConfig
I guess we should add a step at the end of the basic tutorial to at least show the user how to add navbar/footer items?
As a temporary workaround, I mentioned those in #8032
All reactions
Hi there nice tutorial!
I'm looking into the Markdown Features Section, specifically at the Images. Here I see this You can reference images relative....
Screen Shot 2022年10月30日 at 12 06 10 AM
It seems that link at the end is taking users to the wrong place
Screen Shot 2022年10月30日 at 12 06 38 AM
Even if you go to the tutorial extras site you'll see this
Screen Shot 2022年10月30日 at 12 06 53 AM
Am I missing something about where that part of the tutorial is?
Thanks!
All reactions
Thanks. There's actually an example on the target page (source code) but I can see how it is confusing. Fixed in #8279
All reactions
Hi. I can't find out anything in the tutorial about changing the sample code languages (currently it defaults to cURL, Go, Node and Python). Assuming it is possible for a mere mortal to change this via configuration, could this please be included in the documentation?
Thanks!
All reactions
@ianp-its I don't understand what you mean
currently it defaults to cURL, Go, Node and Python
??? please explain what you mean by that
could this please be included in the documentation?
This issue is for the tutorial, and it is kept short on purpose. Maybe it would be better to document what's missing in the official doc site instead?
All reactions
No worries. My mistake.
All reactions
I'm not sure if I'm the right target audience as I don't know javascript (is it mentioned anywhere that knowing javascript is a prerequisite?), but I got a bit stuck at the translation part (https://github.com/facebook/docusaurus/blob/main/packages/create-docusaurus/templates/shared/docs/tutorial-extras/translate-your-site.md).
The tutorial instructs me to modify docusaurus.config.js to add support for the fr locale:
export default {
i18n: {
defaultLocale: 'en',
locales: ['en', 'fr'],
},
};
But in the used "my-website" project, the config file only has an i18n object within "const config". So it's not clear what I am supposed to do with this snippet, append it to the end of the file? Replace the "export default" part at the end of the file?
Copilot tells me I should simply edit the existing i18n part under "const config", which seems to make sense, but it won't match the snippet in the tutorial.
All reactions
Yes you can modify the i18n attribute directly, using export default {} or export default config leads to the same for JS: the config object you write gets exported.
All reactions
Hi, it's not exactly a bug (more PIBKAS) but FYI, when I first created 2021年02月28日-greetings.md in vscode, I mistakenly created it as a folder. Deleting the folder and creating a file didn't then get the md show. Worked as expected after re-serving the site (ctrl-c / npm start)
All reactions
-
👍 1
Hi, thanks for the great tutorial.
At "Deploy from command line" section of the "Deployment" page, I needed to use
USE_SSH=true
instead of
GIT_USER=<Your GitHub username>
since I use SSH to connect to github. If you could mention this as info, it will be appreciated.
All reactions
The tutorial is written under the assumption that when the user created their site, they selected JavaScript.
If the user selected TypeScript, the user cannot complete all parts of the tutorial, especially the Extras.
Moreover, it is extremely hard to find any documentation anywhere that explains how to switch from TypeScript to JavaScript. What's that you say? It's not possible to do that? Then there should be "dead end" documentation that explains that a site cannot be switched from one to the other.
Question: Should the prompt for JavaScript over TypeScript really not mention the need to accept the default if one expects to understand Docusaurus in 5 minutes. If this caution already appears somewhere, would you please draw my attention to that location?
All reactions
Thanks for the feedback @dgcuff
The tutorial is written under the assumption that when the user created their site, they selected JavaScript.
If the user selected TypeScript, the user cannot complete all parts of the tutorial, especially the Extras.
Can you tell us which part of the extra tutorials, especially?
From what I see, both versioning and i18n should work for the TS case too. The only quite minor difference is that the tutorial asks to modify docusaurus.config.js and not docusaurus.config.ts, but it seems reasonable that the user will this out?
Moreover, it is extremely hard to find any documentation anywhere that explains how to switch from TypeScript to JavaScript. What's that you say? It's not possible to do that? Then there should be "dead end" documentation that explains that a site cannot be switched from one to the other.
Where have you looked for?
It's at the beginning of our docs, and you can definitely add TS support to an existing site following the instructions here: https://docusaurus.io/docs/typescript-support
The embedded tutorial is only a tiny subset of Docusaurus, and you have to read the official documentation for more details.
Question: Should the prompt for JavaScript over TypeScript really not mention the need to accept the default if one expects to understand Docusaurus in 5 minutes. If this caution already appears somewhere, would you please draw my attention to that location?
I don't understand what you mean sorry 😅
All reactions
Well, of course, I could be wrong — perhaps the tutorial is broken for both JavaScript and TypeScript. But as written, I found two problems with the tutorial:
- Nitpick: The Tutorial sample file claimes that you could silence the blog feature by setting blog to "false":
And if you don't want a blog: just delete this directory, and use blog: false in your Docusaurus config.
This sample file contains outdated information and that outdated information should be removed if it cannot be corrected (because revisionist history is bad). In the .config file, the only boolean associated with the blog feature is showReadingTime. If you say, "Well, that's just a sample file," then I lose sympathy with you.
- Serious: The Tutorial Extras section on translation says to add this code to the config file.
export default {
i18n: {
defaultLocale: 'en',
locales: ['en', 'fr'],
},
};
First, the tutorial says that the config file is named docusaurus.config.js, which means that anyone who installed TypeScript will not be able to find the file. That’s just sloppy technical writing based around incorrect assumptions. There’s "happy path" writing, which is fine, and then there’s "the moon belongs to America" writing, which is not. This definitely falls into the latter category, which states that "the Happy Path is the One True Way, Forever and Ever." It is simply inappropriate to pretend to hold the user's hand, as a good tutorial should, and then drop it with a light "Experiment! I won't always be around to tell you what to do."
If the name of the file changes, there should at a bare minimum be a note to that effect. In other words, I absolutely say "No" in response to your question, "but it seems reasonable that the user will [figure] this out?"
Second, simply adding the code breaks the build. The user cannot complete the task. Now, perhaps it breaks because the user is not using the operating system you assume everyone uses, or the user has not followed your idea of the Happy Path. But that's not the user's responsibiity.
It is perhaps not surprising that adding the code block as directed -- and making no other changes -- breaks the build since the final line of the config file is currently this:
export default config;
...which at least appears to create a conflict, if having the build break is anything to go by.
The tutorial says to add the code. That’s all. It should be explicit about how to add the code, and I’m not troubleshooting for Meta for free. You tell me (in the tutorial, please, not in a forum):
- Should the code block replace
export default config;? - Should the code block appear before
export default config;? - Should the code block appear after
export default config;?
I can tell you that replacing the code causes the build to break, and I can tell you that adding the code after export default config; also causes the build to break.
Which issue was already raised in this forum on 2024年08月07日, and yet that lack of clarity failed to prompt anyone to clarify the writing of the tutorial.
Lazy writing — in a tutorial of all places — makes me move on to a better solution. It most emphatically does not make me want to spend my time debugging either the vagaries of any system nor the vagaries of its documentation, but very particularly not the part of the documentation that believes itself to be a tutorial.
The most dangerous sentence in your response is "it seems reasonable that the user will..." and I do not believe that a tutorial should be anything but 100% bulletproof. Having read your reply and noted your attitude on this forum, I can see that we do not agree.
Just as we don't have to agree on the philosophy on tutorial writing, I likewise do not have to invest my time in a place where I perceive the commitment to user communication to be less than rigorous.
All reactions
Well, of course, I could be wrong — perhaps the tutorial is broken for both JavaScript and TypeScript. But as written, I found two problems with the tutorial:
- Nitpick: The Tutorial sample file claimes that you could silence the blog feature by setting blog to "false":
And if you don't want a blog: just delete this directory, and use blog: false in your Docusaurus config.
This sample file contains outdated information and that outdated information should be removed if it cannot be corrected (because revisionist history is bad). In the
.configfile, the only boolean associated with the blog feature isshowReadingTime. If you say, "Well, that's just a sample file," then I lose sympathy with you.
I'm not sure I understand. blog: false definitely works; this is not outdated information. The blog attribute is already here in the default preset config.
blog is not an option of the blog plugin, it's the preset attribute.
I think what you thought you had to do is this: {blog: {blog: false}}, while you only had to do {blog: false}
At best, we could only be a bit more precise? 🤷♂️
- and use blog: false in your Docusaurus config. + and use blog: false in your Docusaurus preset config.
- Serious: The Tutorial Extras section on translation says to add this code to the config file.
export default { i18n: { defaultLocale: 'en', locales: ['en', 'fr'], }, };First, the tutorial says that the config file is named
docusaurus.config.js, which means that anyone who installed TypeScript will not be able to find the file. That’s just sloppy technical writing based around incorrect assumptions. There’s "happy path" writing, which is fine, and then there’s "the moon belongs to America" writing, which is not. This definitely falls into the latter category, which states that "the Happy Path is the One True Way, Forever and Ever." It is simply inappropriate to pretend to hold the user's hand, as a good tutorial should, and then drop it with a light "Experiment! I won't always be around to tell you what to do."If the name of the file changes, there should at a bare minimum be a note to that effect. In other words, I absolutely say "No" in response to your question, "but it seems reasonable that the user will [figure] this out?"
I agree this is a problem, although it's quite easy for most users that docusaurus.config.js and docusaurus.config.ts are the same Docusaurus config file depending which option you choose at init time. You can rename from/to .js and .ts extensions, we support both.
So far you are the only one in years that complained about that, but I'm ok to improve. Would you consider docusaurus.config.{js,ts} be a better alternative, considering we don't want to duplicate our tutorial content for such a tiny detail.
Second, simply adding the code breaks the build. The user cannot complete the task. Now, perhaps it breaks because the user is not using the operating system you assume everyone uses, or the user has not followed your idea of the Happy Path. But that's not the user's responsibiity.
It is perhaps not surprising that adding the code block as directed -- and making no other changes -- breaks the build since the final line of the config file is currently this:
export default config;...which at least appears to create a conflict, if having the build break is anything to go by.
The tutorial says to add the code. That’s all. It should be explicit about how to add the code, and I’m not troubleshooting for Meta for free. You tell me (in the tutorial, please, not in a forum):
- Should the code block replace
export default config;?- Should the code block appear before
export default config;?- Should the code block appear after
export default config;?I can tell you that replacing the code causes the build to break, and I can tell you that adding the code after
export default config;also causes the build to break.
The tutorial says exactly:
CleanShot 2025年09月25日 at 16 41 07@2xWe are not saying "adding" nor replacing.
We are saying that you should edit this:
CleanShot 2025年09月25日 at 16 42 00@2xto this:
CleanShot 2025年09月25日 at 16 42 23@2xWhich issue was already raised in this forum on 2024年08月07日, and yet that lack of clarity failed to prompt anyone to clarify the writing of the tutorial.
It seems to me that both of you read the tutorial too fast and then blame us. Again, "modify" is not the same as "add" or "replace.
Lazy writing — in a tutorial of all places — makes me move on to a better solution. It most emphatically does not make me want to spend my time debugging either the vagaries of any system nor the vagaries of its documentation, but very particularly not the part of the documentation that believes itself to be a tutorial.
The most dangerous sentence in your response is "it seems reasonable that the user will..." and I do not believe that a tutorial should be anything but 100% bulletproof. Having read your reply and noted your attitude on this forum, I can see that we do not agree.
Just as we don't have to agree on the philosophy on tutorial writing, I likewise do not have to invest my time in a place where I perceive the commitment to user communication to be less than rigorous.
I'm also taking note of your attitude toward OSS developers, providing you with software for free. Please go find a better tool/community and annoy another maintainer. Your attitude is not constructive either, and after reading this wall of text, I'm also bitter that I spent time trying to answer you.