May 27, 2021 Web Cloud Development and Web Hosting Learning Guide
2. Install cloud development cli tools and Hexo
3. Create a cloud development environment
Hexo is a widely used static blogging system, and in addition to github Pages deployments, now you have a new option: use the cloud to develop static site features to deploy!
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 Hexo
npm install -g @cloudbase/cli hexo-cli
Initialize a Hexo project locally
First, let's create a Hexo project and execute the following command
hexo init
You can see the output below
Once the initialization is complete, go into the directory and start the preview
cd blog
hexo s
Then, when you open localhost:4000 in your browser, you can see Hexo's interface, which shows that we have successfully initialized Hexo locally
After completing the on-premises Hexo build, let's create a cloud development environment to deploy Hexo. 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 if you have more blog posts, it's easier to upload them using Cli).
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, uploading and deploying Hexo.
Back in your Hexo directory, execute Hexo g to generate the file, and Hexo generates the file in the Public directory by default.
Once the file is generated, you can deploy by executing the following command (you need to replace EnvID with the environment ID you noted earlier)
cd public
tcb hosting:deploy ./ -e EnvId
Wait a few moments, the deployment is complete, and then you're ready to preview.
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
With just a few simple steps, you can easily deploy Hexo to cloud development without having 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
Click on the link below to quickly start deploying your site with cloud development static site hosting: https://console.cloud.tencent.com/tcb?from=12304
CloudBase is a cloud-based, all-in-one product solution that uses serverless architecture, environment-free construction, and other operations, supporting one cloud and many ends, helping to quickly build small programs, web applications, and mobile applications.
Technical documentation: https://www.cloudbase.net/
WeChat Search: Tencent Cloud Cloud Development to get the latest developments in the project