Docusaurus: Sidebar title and doc title don't change after updating it in file.

Created on 29 Jun 2018  路  25Comments  路  Source: facebook/docusaurus

Is this a bug report?

Yes

Have you read the Contributing Guidelines on issues?

Yes

Environment

Docusaurus v1.3.0
NPM v6.1.0
Node v8.11.3
Macbook Pro with MacOs High Sierra

Steps to Reproduce

Tried to reproduce it in a fresh Docusaurus project, but can't reproduce it there. What I can say about my own project is that it already has a lot of markdown files. I also have all of them in subdirectories inside the docs folder, so I also refer to them via their relative path in my sidebars.json file.

  1. Have the dev server running
  2. Have an existing docs file with its relative path in sidebars.json
  3. Change the title of the doc file
  4. Restart dev server

When building the project it also updates fine.

Expected Behavior

I expected the title to change to the new one in the sidebar and in the h1 header. This does not happen.

Actual Behavior

Title in sidebar doesn't change and the h1 header doesn't change, which used to work before, but sudddenly stopped working.

Sometimes I see this error in the console:

uhoh. Got error write EPIPE

But most of the time it doesn't show up.

I also asked this in the Discord channel and got a workaround:

  • Remove the i18n folder
  • Run npm run write-translations
  • Start dev server
  • Everything updates like normal

Reproducible Demo

Could not reproduce it in a fresh docusaurus project and can't share my own project here. If more details are needed I can provide them.

bug

All 25 comments

@KoenCa

  1. is it specific only to certain docs or any docs won't trigger the change of title ?
  2. Did you try to rm -rf node_modules and reinstall ? Clearing the babel cache as well
  3. Do you use versioning and/or translation ?

@endiliey

  1. I tried several different docs, none worked.
  2. I tried removing node_modules several times, also cloning my project again from GitHub. Only thing that works is removing that en.json file and running write-translations again. When I look in this file it is also incorrect.
  3. At the moment I don't use versioning or translation. But versioning will be added when first version of docs is ready.

Maybe it has something to do with the fact that I use subdirectories for my doc files? I also don't addy any id's to my doc files. I tried adding Id's but then docusaurus could not find the file by id.

@KoenCa

That's weird. My website use id on docs & warriorjs use subdirectories for all their docs with id too. You can check how warriorjs use subdirectories https://github.com/olistic/warriorjs/blob/master/website/sidebars.json

If your docs is in docs/projectA/test.md with id test then it should be referred as projectA/test in sidebars.json

Can you try adding id and see if it works ?

@endiliey

  1. Added id to a doc file
  2. Changed relative path in sidebars.json accordingly
  3. Restart sever and navigating to page still works
  4. Change title
  5. Restart server and again no change

Adding an id doesn't work.

I seem to get this error quite often now while change title attritube or others:

... Uhoh. Got error write EPIPE ...
Error: write EPIPE
    at _errnoException (util.js:992:11)
    at WriteWrap.afterWrite (net.js:864:14)

But it doesn't crash my development server and live reloading of text on pages still works.

@KoenCa

Can you try to remove i18n folder -> npm run write-translations -> change some docs title -> npm run write-translations again and see if the title is changed in i18n/en.json

Do not run dev server

Since the workaround is related with deleting i18n I think it got to do with write translation

Deleting your current en.json should work and then do the right thing since you are on 1.3.0 -- although you can upgrade to 1.3.1 now too.

@endiliey

Just tried it, it does change the en.json correctly when I follow your steps. Maybe it doesn't work properly when the dev server is running?

@JoelMarcey

I don't see any 1.3.1 release yet?

馃ぃ I got ahead of myself. I thought it went out last night. Should be today.

@KoenCa

so the workaround step has been reduced to

  1. Run npm run write-translations
  2. Start dev server

Does Everything updates like normal ?

@endiliey

Yes, it is not necessary to remove the en.json file. Everything updates like normal without removing it.

BTW, maybe I should add that I first started with v1.2.0, then upgraded to v1.2.1 and then upgraded to v1.3.0.

@KoenCa

So if you only start dev server without running npm run translation, the title won't change ?

If yes, I think the problem is that dev server doesnt run write-translations when it should have

https://github.com/facebook/Docusaurus/blob/e9eef3976025c9f428baec725e6daf929384b5fb/lib/server/server.js#L9
https://github.com/facebook/Docusaurus/blob/e9eef3976025c9f428baec725e6daf929384b5fb/lib/server/server.js#L156

@endiliey

Yes, changing title and only starting dev server won't change it. When running npm run write-translation it does change.

@endiliey

Or this function goes wrong?
https://github.com/facebook/Docusaurus/blob/e9eef3976025c9f428baec725e6daf929384b5fb/lib/write-translations.js#L33

And thats why I sometimes get this error?

... Uhoh. Got error write EPIPE ...
Error: write EPIPE
    at _errnoException (util.js:992:11)
    at WriteWrap.afterWrite (net.js:864:14)

@KoenCa

Seems so to me. This works for me but I think it didn't work for yours

test

Can you try above step & let me know abt the logs that appears ?

In the docusaurus project or my own?

@KoenCa yours

Just for context how many markdown files do you have 馃槀

I just get logs like this:

> @ start /Users/koen/Documents/github/dovetail-docs/website
> docusaurus-start

Docusaurus server started on port 3000
LiveReload server started on port 35729

The error log mostly happens when the server is already running.

I have 78 markdown files at the moment and more will come. I also have 48 PNG images in my docs assets.

Tbh, it's a little bit hard for us to fix without reproducible demo

How about this. We'll release 1.3.1 soon. Let's see if that solve your problem later. Otherwise I might need you to give me a reproducible repo, maybe you can omit the docs content if it's confidential. Sorry for the trouble

No problem, I understand.

@KoenCa
In the meantime, you can use this solution. Edit your package.json

"start": "docusaurus-write-translations && docusaurus-start",

Let me know if it works 馃槉

@endiliey

Yes, it works 馃憤

@KoenCa I wonder if you still have the problem ? Couldn't find any similar report so I'll be closing this.

Ping me on Discord if needed

image

Still, title issue comes for us. Why that?
tried Deleting en.json file and tried changing package.json.
Kindly help

i meet this situation too , i use v1.14.4

1

my solution

  • remove all files from this folder
  • use code editor create new files with same name one by one
  • copy content from old to new
  • restart dev server

2

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NikitaIT picture NikitaIT  路  3Comments

azu picture azu  路  3Comments

rickyvetter picture rickyvetter  路  3Comments

chandankumar4 picture chandankumar4  路  3Comments

lex111 picture lex111  路  3Comments