Walkthrough Part I: Generate a Simple Documentation Website
By completing this walkthrough, you'll become familiar with the workflow of docfx and the general principle of organizing documents inside docfx. You will finish this walkthrough with a static website that can be published to any host service. Download the files used in this walkthrough here.
Step1. Setup DocFX
Download docfx from http://dotnet.github.io/docfx/. Getting Started with docfx describes three ways to install docfx. This walkthrough uses the first one: Use docfx.exe directly.
- Download docfx.zip and unzip it to
D:\docfx\ - Add
D:\docfx\toPATHso that commanddocfxand be directly called from everywhere for convenience. (for example, for Windows,setx PATH "%PATH%;D:\docfx\"
Step2. Init a DocFX project
- Create a new folder
D:\docfx_walkthrough - Start Command Line under
D:\docfx_walkthrough - Call
docfx init -q. This command generates adocfx_projectfolder with the defaultdocfx.jsonfile under it.docfx.jsonis the configuration filedocfxuses to generate documentation.-qoption means generating the project quietly using default value, you can also trydocfx initand follow the instructions to provide your own settings.
Step3. Build our website
Run command docfx docfx_project/docfx.json. Note that a new subfolder _site is generated under that folder. This is where the static website is generated.
Step4. Preview our website
The generated static website can be published to GitHub pages, Azure websites, or your own hosting services without any further changes. You can also run command docfx serve docfx_project/_site to preview the website locally.
If port 8080 is not in use, docfx will host _site under http://localhost:8080. If 8080 is in use, you can use docfx serve _site -p <port> to change the port to be used by docfx.
Congrats! You can now see a simple website similar to:

Step5. Add a set of articles to the website
- Place more
.mdfiles toarticles, e.g.details1.md,details2.md,details3.md. If the file references any resources, put those resources into theimagesfolder. In order to organize these articles, we add these files into
toc.ymlunderarticlessubfolder. The content oftoc.ymlis as below:- name: Introduction href: intro.md - name: Details 1 href: details1.md - name: Details 2 href: details2.md - name: Details 3 href: details3.mdSo now our folder layout is:
|- index.md |- toc.yml |- articles | |- intro.md | |- details1.md | |- details2.md | |- details3.md | |- toc.yml |- images |- details1_image.png- Run Step3 and Step4 again, and the website is now:
.
Notice that more items are added to the sidebar for Articles nav page. The title inside the sidebar is exactly what we set in the toc.yml inside articles subfolder.
Conclusion
In this walkthrough, we build a website from a set of .md files. We call these .md files Conceptual Documentation. In walkthrough part 2, we will learn to add API Documentation to our website. The API Documentation is extracted directly from .NET source code. In a series of advanced walkthroughs, we will learn advanced concepts in docfx, such as cross reference between articles, external reference to other documentations, etc. We will also learn to customize our websites, from theme to layout to metadata extraction.