5

When I run docfx docfx.json --serve and go to localhost:8080, I see two items on the top menu: "Articles" and "Api Documentation". When I navigate in the filesystem to _site\ and click on index.html to open it in Chrome, these menu items are missing. How can I make sure the menu is properly set when I run it as a static site?

I need to be able to package the html files and send them to people for them to view locally without them having to download the repo and install docFX.

devlord
  • 4,054
  • 4
  • 37
  • 55
  • Does it help you to look at _site\toc.html? – hcdocs May 13 '19 at 21:03
  • When I do that I see (unformatted) ``` [ Enter here to filter ] * Articles * Api Documentation ``` And both those pages are missing any navigation. – devlord May 13 '19 at 22:44

1 Answers1

10

Reason: The page needs extra JS files to the navigation bar, but it is blocked by Chrome. You can see these errors in Chrome console (F12):

docfx.vendor.js:4 Access to XMLHttpRequest at 'file:///C:/git/docfx-seed/_site/toc.html' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
send @ docfx.vendor.js:4
docfx.vendor.js:4 Access to XMLHttpRequest at 'file:///C:/git/docfx-seed/_site/logo.svg' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

Solution: Use template statictoc, which already embedded all the required parts into HTML file:

docfx docfx.json -t statictoc
Yuby
  • 808
  • 7
  • 19
  • I was beginning to think DocFx wasn't an option... `-t statictoc` fixed it right up. Thank you! – owns Jun 02 '20 at 05:09