About the author: Tangleithu (ID: Tangleithu), currently a technology expert of Alibaba, a poor student of Tsinghua University, and a former back-end Leader of DJI. The public account background reply keyword “1024” to obtain the programmer interview guide.
Drone Promotions from SkyPixel
background
Stone got his first domain name around 2010 and started blogging around that time. Ten years, indeed.
Initially play blog, in fact more or hold the attitude of learning. For example, just learned DNS parsing, HTML syntax, don’t “actual” a? Then, I successively put my reading notes and course summaries on my blog.
Why should write a blog, stone thinks there are several benefits as follows:
-
Can use it as a place to organize study notes, convenient precipitation learning, as I started to play. It’s more for myself, playing around with the “site building” process (independent blogging), which is also a small skill. (Whether to write a blog or not depends on personal interests, but learn to sum up the precipitation is necessary)
-
“Be good for yourself and help others.” In your daily work, you’ve probably solved a problem through someone else’s blog, so it’s a good idea to feed the open Internet back to you. When someone searches your content through a search engine and leaves a message saying thank you for helping him solve a similar problem, there is still a sense of accomplishment.
-
Practice writing. Understand a problem and tell it to others to understand, are two completely different concepts.
-
Create your own IP. For example, the famous Coolshell, Ruanyifeng, etc., most people should know?
-
To make money. I don’t need to say much about that. Say it out, you may not believe, even I 10 years ago did not have what content of the blog, at the beginning also have “extra money” to earn: remember at the beginning is to “friends chain” way to guide the flow, a month 5~10, just can cover the domain name, virtual host costs, but later all kinds of blog move, also too lazy to do something about.
-
.
Through these 10 years of exploration, Stone also tried a variety of ways to write blog. But say ashamed, also seem to have nothing to say achievement.
At present, I have accumulated more than 400 articles, but I feel that there are only dozens of articles with real quality. I’ve been through a lot of blogging programs, and I’ve moved several versions off and on, and I’ve kept my historical articles. In fact, many articles seem to be of little value to me now, but still reluctant to abandon, after all, the original hard to Po out. Those who are interested can visit the website “www.tanglei.name”.
Following the evolution of my blog as an example, to introduce the common blog play, for your reference.
The evolution of blogs
Pure wordpress
I’m not going to talk much about wordpress, but it’s a CMS that’s developed in PHP, and a lot of people use it for their blogs.
Below is a rudimentary version of my blog, which I have been using for quite some time.
WordPress blog
“How time flies,” and the screenshot above is also interesting —
-
The top right corner of the dynamic “Tencent micro blog”, do not know you have used?
-
The Rss feed in the upper left corner, I don’t know if there are still people using it, are there many people using it? I haven’t opened my subscription in a while anyway.
Using WordPress to write a blog, there is a disadvantage is that every time writing needs to log in the background, typesetting, graphics and other more troublesome. They also have to pay for virtual hosts, operate and maintain their own wordpress programs, MySQL and so on.
Then I came across the markup language MarkDown, and I realized that it was so good, and I couldn’t stop it. Writing with Markdown is still used today.
WordPress + MarkDown plugin
If you want to keep the blog theme, you can always use wordpress, but hopefully write markdown.
I couldn’t find a markdown plugin for wordpress, so I wrote my own markdown2wordpress (github.com/tl3shi/mark… In wordpress, cumbersome typography and other problems can be directly handed over to Markdown, and there is no need to log in to the background of wordpress for adjustment and other operations.
The tool relies on Python-Wordpress-XMLRPC, a Python implementation of the wordpress client that can easily invoke the interface provided by wordpress. Markdown rendering relies on Pandoc. The code is highlighted using highlight.js images in the form of a map bed, or directly as a link out of Github.
I used this tool for a while longer.
But the stone had bought the virtual host (shared type) or a public form of many individuals, poor performance, the website is often hung, a virtual machine hung, MySQL hung for a while, and then also in the Trojan. I just can’t stand it.
Making page service
The Github Page service is pages.github.com/. On Github, all you have to do is edit, push, and change is immediately visible.
Not only do you save money on hosting, MySQL, etc., but github Page also supports custom domain names, Git versioning, and automatic markdown rendering is tailor-made for programmers (as it seems to be).
The programmer just concentrates on writing markDown files, rendering HTML and so on to Gitub.
Below is a screenshot of my setup.
Github and Octopress configuration
The detailed process can be found in my Blog:
-
Making up blog tutorial: www.tanglei.name/blog/use-gi…
-
Also try making + octopress: www.tanglei.name/blog/github…
In the process of building, also involves the migration history articles, etc., interested can refer to _ eventually gave up WordPress_ (www.tanglei.name/blog/give-u…
The good thing about Github Pages is that the only thing that bloggers really care about is writing Markdown (like writing papers in latex), and they don’t care about things like typesetting in the background of wordpress, uploading pictures, and so on.
github pages + travis-ci
The Github Pages service itself supports fewer blog engines, such as customized plug-ins, than the default github Pages service.
But essentially, the Github Pages service provides a custom domain name resolution repo to static HTML. Github does not support the process of converting MarkDown to HTML enough, so you can do it in other ways.
Write MarkDown locally, install a blogging engine like Hexo locally, render it as HTML, and push it directly to the github page’s remote repository.
I have used several blog engines, as shown below:
▲ Jekyll’s blog theme
▼ hexo theme
Here’s a recommended tool — Travis, it’s a free CI tool, what can you do for you? That is, your local processes above can be delegated to it. My current blogging process is:
-
Write blog locally, md format. Tools can be used directly with the markdown writing tools Macdown or Typora in the previously recommended programmer tools.
-
Git commit && git push
-
Travis gets to work, installing the blog program, then building the static HTML, and finally pushing it to the specified Github Pages repository.
Post my Travis configuration and you’ll see how it works.
branches:
only:
- master
language: node_js
# v14/stable(2020-05) produces empty html https://github.com/hexojs/hexo/issues/4257
node_js:
- 'v13.8.0'
cache: npm
before_install:
- git config --global user.name "tangleithu"
- git config --global user.email [email protected]
install:
- npm install hexo-cli -g
- npm install
script:
- hexo clean
- hexo g
- git log | head -n 6
- export COMMIT=`git log | head -n 1`
- mv public .deploy && cd .deploy && du -sh
- git init && git add -A . && git commit -m "commit from travis, origin $COMMIT"
- git push --force "https://tl3shi:[email protected]/tl3shi/hexo.tanglei.name.git" master:gh-pages
Copy the code
As you can see from the configuration above, all you’re doing is installing hexo, generating static HTML, and then packaging the whole locally generated static HTML as a repository and pushing it to the corresponding repository on Github Pages.
The configuration page of Travis-CI is shown below. It can be configured to trigger the CI process, for example, with a new Commit push to update the blog.
Travis configuration
Although the whole process may seem complicated, in fact, the installation and other processes can be cached. Generally speaking, the entire process takes only 1-2 minutes (as shown in the figure below). Because my blog content is “burdened with history”, it may take much longer. Much of the time depends on the process of the blog application and the final Git upload process.
Below is the build history, you will be notified by email if the build is successful, very convenient.
Travis builds history
There’s a lot to play with with Travis, and the scripts are flexible enough to customize.
For example, can the same article more than one platform. For example, it is now common for all blogs to publish at the same time. Can we directly add Juejin, Blog Garden and other post processes into the CI process?
Interested friends to try? (Stone has had this idea for a long time, but has never acted on it)
Fix github slowness
Github is indeed very convenient to use, a variety of free services white Piao, but the disadvantage is more obvious, domestic access is slower than good. Gitee offers a similar service, but after a quick look at it, it looks like there’s a charge for custom domain names?
A simpler approach is to use CDN to solve this problem. The blog itself is full of static resources, HTML, images, etc., which are well suited for CDN acceleration.
In this piece of cloud server, domain name for the record and the CDN service experience (www.tanglei.name/blog/try-qc…
The working process of CDN is that you add the CNAME of a domain name, pointing to the domain name of the CDN manufacturer. Therefore, when the user initiates a request, it is actually resolved to the CDN server of the cloud manufacturer. The CDN background configures a source site, such as www.tanglei.name. If there is no hit, the request goes to the source site and the content is cached to the CDN server.
Below is a screenshot of the CDN I tested earlier.
CDN configuration renderings
Below is the test result of visiting a page with some images, where:
-
Requests to www.tanglei.name are routed directly to the github Pages file;
-
The CDN of the cloud vendor can be accessed through www.tanglei.me.
CDN test result tanglei.name
A 10KB page loads in about half a second, which is plenty for a personal blog. Some of the results in the graph above, such as the USA, are lower than the average, and some nodes abroad are still faster on Github. If you need to do global acceleration, you can also use our company’s global acceleration service (CDN includes many overseas nodes).
The last
This article is just a stone in the process of exploration to find the right way to their own, everyone likes the pose may be different, this article is for reference only, hope you can find the right posture for you.
Feel this number to share the article is valuable, remember to add star mark oh. Don’t be white piao, we need positive feedback. How about arranging a “three-click” (like, watching, share)? 😝 This will be my greatest motivation to continue producing great articles.
About the author: Tangleithu (ID: Tangleithu), currently a technology expert of Alibaba, a poor student of Tsinghua University, and a former back-end Leader of DJI. Share high quality technical articles with different perspectives, with the purpose of every article to let people have harvest, welcome attention, communication and guidance! The public account background reply keyword “1024” to obtain the programmer interview guide.
Recommended reading
Join us soon — “Aliyun-ECS/Shenlong Computing Platform” is hiring. Tell me about the shuffle algorithm and its application scenarios!
After seven rounds with Google, he was finally doomed
With this guide to interview programmers, are you any closer to a job Offer at a big factory? | recommended books
School students, there is a programmer for summary is waiting for you to take 10 + company | interview, 8 Offer school recruit experiences to share