May 27, 2021 Web Cloud Development and Web Hosting Learning Guide
2. Install cloud development cli tools and Gitbooks
3. Initialize a gitbook eBook project locally
4. Create a cloud development environment
Cloud Development Static Hosting is the ability to host static websites provided by cloud development, and the distribution of static resources (HTML, CSS, JavaScript, fonts, etc.) is supported by Tencent Cloud Object Storage COS and Tencent Cloud CDN with multiple edge outlets
GitBook is an open source e-book generation tool that can easily help you build simple and generous e-books, and of course, cloud development now supports the deployment of GitBooks
Before you go on, make sure you have Node installed in your PC .js the environment. If it is not installed, you can nodejs.org download the installation.
Follow these commands to install the cloud development cli tool and Gitbook
npm i -g @cloudbase/cli gitbook-cli
First, let's create a gitbook e-book project and execute the following commands to create an e-book
gitbook init book
In this way, we create a new e-book in the book directory.
You can execute the command to preview him
cd book
gitbook serve
After successful launch, open the browser's localhost:4000 and you can see the eBook we just created
This means that we have completed the initialization of the project.
Now that we've created your on-premises Gitbook, let's create a cloud development environment to deploy your Gitbook. Open the Tencent Cloud Console and find cloud development in the product
Go to the cloud development management console, click New Environment, Create New Environment for deployment
Create a new environment, called docs, and choose to bill by volume to open the environment
After you open your environment, remember your environment ID, which we'll use later.
Once the creation is complete, click on the environment and go to the environment management page. Click on the "static site" in the menu bar on the left
And in the static website page opening function
When you see an interface like this, it's already open.
You can now manually upload a file test by uploading a file, and later we'll use cloud development Cli to complete the upload.
Once we've configured our cloud development environment, we need to initialize the cloud development cli so that we can upload pages with cli (of course, you can upload them directly from the web side, but Gitbook is easier to upload with Cli if you have more document pages).
Enter the following code on the command line
tcb login
will remind you that you need to authorize on the web page
Confirm authorization on the pop-up page
After confirming the authorization, you will see the console output the appropriate command
That way, your cloud development cli is initialized. Next, you're ready to move on to the last step and upload the deployment Gitbook.
Next, let's build the HTML for the Gitbook, which by default generates HTML in the _book directory. We can upload and deploy the files in this directory and execute the following commands (remember to replace envId with your own environment ID)
gitbook build
cd _book
tcb hosting:deploy ./ -e envId
Click settings, go to the settings page, you can find the default domain name, click on the domain name, you can see the environment you just deployed.
For example, this is what happened after my deployment
In this way, your deployment is complete
Deploy your Gitbook to cloud development in just a few simple steps, eliminating the need to endure the speed of Github Pages! Not moving fast yet?
Not only that, but if you're an automation enthusiast, try configuring the Cloud Development Cli into your CI environment for automatic deployment