mdBook is a static site generator based on Markdown files, which can be used to quickly create personal blogs, documentation pages, or websites. Here are the brief steps to deploy your own website using mdBook:
-
Install mdBook: Go to the GitHub page of mdBook to download the latest version of mdBook, and follow the official documentation for installation.
-
Create mdBook project: Create a new mdBook project on your local computer using the following command:
mdbook init mysite
This will create a new project named "mysite" in the current directory.
-
Write Markdown files: Write Markdown-formatted documents in the "src" folder of the mdBook project. These documents will be automatically converted into HTML pages. You can use Markdown syntax to write document content, as well as some special syntax provided by mdBook to set page layout, add navigation, etc.
-
Preview the site: Preview the generated site locally using the following command:
mdbook serve --open
This will start a local server that allows you to preview the generated site in your browser. You can access it by visiting http://localhost:3000.
-
Build the website: When you are satisfied with the appearance and content of the site, use the following command to build the final static website files:
mdbook build
This will generate a folder named "dist" that contains the generated HTML, CSS, JavaScript, and other files.
-
Deploy the website: Upload the generated "dist" folder to your web server or static hosting platform, such as GitHub Pages, Netlify, etc., to deploy your website on the internet.
After uploading your repository to GitHub, click on "Settings" and find "Pages" inside. Here, we will use GitHub Pages to deploy the website.
Then, go to "Build and Deployment" and choose "GitHub Action" as the source.
Next, click on "configure" in mdBook and use the default configuration provided.
After committing the code, wait for the GitHub Action to finish running, and you will have your own website homepage.