Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”
This article has participated in the “Digitalstar Project” and won a creative gift package to challenge the creative incentive money.
The committee recently launched a Py4Ever open source site using Hexo.
Here is the site information: Py4ever open-source site
It is based on Hexo, with some customization, of course.
This time, the student committee gave step-by-step instructions on how to set up a blog.
What is a hexo
Hexo is a blog generation tool based on the Markdown syntax of blog generation.
Hexo has also released a NODEjs-based CLI library (command-line tool), which can be found at NPM.
It is simply a blog site factory that generates blog sites, but in its own way.
Learn the steps for Hexo to generate a blog.
The installation
Global installation, adding the hexo command to the PATH variable of the runtime environment so that it can be used anywhere.
npm install -g hexo-cli
Copy the code
Usually we install a library and immediately look at the version/help to make sure it’s working
hexo -v
Copy the code
The first step is to generate the site project
Run the following command to create the blog project:
hexo init
Copy the code
This command will quickly generate the blog template file.
This site is a standard NodeJS project.
As shown below, there are many files, particularly package.json, which replicates the libraries of other dependencies that manage the project.
Then there are themes, which are the theme style of the blog, the overall style, the layout. Like the Chinese style of music, R&B and stuff, it limits the tune of the whole song, which for us on this blog is the whole look, the whole layout.
And then there are scaffolds: quite simply, creating templates for categories/articles, etc., that can be modified.
Learn more about the NodeJS project:NodeJS hobby series by Ray School CommitteeWe continue to edit the blog page.
Modifying Site Information
As follows, we have modified the title first:
There are other details of operation, our Sir Into the site.
The second step is to generate web pages
To preview your site, you need to create a page for your site, use the following command
hexo generate # or hexo G
Copy the code
This command helps us generate the site from an MD file template to an HTML file. We can see that there is a public directory in the project directory:
This is the HTML file that will eventually be displayed on the blog site. If you know HTML, what you see is what you get. Whatever text and color blocks you put in the HTML, the browser will display accordingly.
Step 3 preview the site
Let’s stick with the default theme and run the following command to see how the site looks after the change.
hexo server
Copy the code
The running effect is as follows:
We can open the browser to view:
The Hexo tool launches a server that renders the blog site we just generated, which is handy.
Also, the blog comes with a blog post, “Hello World,” which Hexo generates by default.
Edit the blog page
We open the Source directory in the blogs folder. It holds the site’s articles.
Here it’s easy, it’s a File in Markdown (MD) format.
Small white can be understood as a document style specification. For example, the beginning of ‘#’ indicates a headline, a level 1 headline. The beginning of ‘##’ indicates secondary headings.
Modify it below:
- Modified title to: Lei Xuewei blog tutorial
- Changed the secondary title to: Quick Start/Quick Start
- Added a line of text: “First line of text (from the Committee)”
We can modify the file content as needed, rerun the following command to see the effect
hexo generate # or hexo G
hexo server # or hexo S
Copy the code
Refresh the previous page and we see that the blog content has changed.
Summary and Extension
This article shows a quick generation of a blog site.
To add a new blog, copy helloWorld.md or use ‘hexo new blog name’.
Simply copy the public directory to the server and render it. But Hexo provides a more efficient approach, which we’ll continue in the next article.
In the next article, the Committee will introduce the technical construction details of py4Ever website in detail.
If you like Python, please pay attention to the ten-year veteran who will teach you to do open source projects or basic Python columns or get started in Python to master the big columns
Continuous learning and continuous development, I am Lei Xuewei! Programming is fun. The key is to get the technology right. Creation is not easy, please pay attention to the collection of likes, or leave a comment to encourage!