Write Markdown articles with Github Actions and automatically update them to WordPress

  • The most comfortable format for blogging is Markdown;

  • The easiest way to manage a blog is WordPress;

  • The best platform to promote a blog is Github;

Github Actions automatically updates posts to WordPress, and WordPres index to Readme.md in Github repository for search engine indexing.

Program permanent open source update address

Github.com/zhaoolee/Wo…

How to implement WordPress login authorization?

WordPress has XMLRPC enabled by default. XMLRPC is a universal blog update standard that allows users to automatically add, delete, modify and review posts in POST mode. The authorization mode is user name and password. In WordPress, the user name and password are used for background login

My WordPress website is fangyuanxiaozhan.com

It’s for fangyuanxiaozhan.com/xmlrpc.php XMLRPC service address

What are the benefits of using Github Actions?

Github Actions allows you to run code without having to install a development environment.

For this project, I can use the mobile version of Git App or Github web page to complete the creation of a new article, and then push it to the warehouse. Github Actions will automatically help me complete the relevant code operation, which can help me update the article to the WordPress website and generate a new article directory index. And automatically updates you to readme. md for search engine inclusion.

How do I protect my WordPress password?

Github has secrets to protect key information such as usernames and passwords. Only Github Actions can read key information.

This project needs to set three secret

  • USERNAME for logging in to WordPress. The variable name is USERNAME
  • PASSWORD for logging in to WordPress. The variable name is PASSWORD
  • Xmlrpc.php for WordPress with the variable name XMLRPC_PHP

How to create a new article?

Create a markdown file with the suffix.md in the _POST directory

Article management: How to categorize/tag articles?

Fill in the following initialization information at the top of the.md file to complete the setting of title, tags, and Categories, where title is required. (These keywords are not defined by me, I borrowed the standard of hexo, a well-known static blog builder.)

Categories: -- I am category 1 -- I am category 2 -- Categories: -- I am category 1 -- I am category 2 --Copy the code

What is the difference between tags and categories?

Tags are the keywords of a single article. For example, the label of banana is yellow and sweet (the label is the attribute of banana). Categories are the belongingness of this article, for example, bananas are classified as fruits and plants

How do I set up fixed links?

For a blog, it is very important to have a fixed link for the article. After various attempts, I finally drew on the url form of The article in Jianshu, adding/P/after the domain name and English file name. As long as the English file name is not changed, the article will have a fixed link. I will create a new 2020-01-18-blog.md file under _posts, and the url of the post will be

Fangyuanxiaozhan.com/p/2020-01-1…

The file name corresponds to the url of the website strictly, which is convenient to modify, and can be quickly recovered from the Github repository in the event of a website database accident (disaster recovery), even the URL will not change.

How to use it?

After the configuration is complete

Run each time a post is added or updated in the _posts folder

git pull && git add _posts && git commit -m "update" && git push
Copy the code

Can!

Github readme. md display effect, (the new article is the first)

WordPress also published articles at the same time

Fangyuanxiaozhan.com/p/2020-01-1…

How to complete blog update operation with mobile phone?

With the hammer note, you can write Markdown in an elegant and comfortable way. The mobile App is very easy to use, and the web version can be used, with 5GB free space, you can write down the hammer.

If you have trouble inserting images, you can use the free chart shell

imgkr.com/#upload

Pocket Git and MT manager can cooperate to complete the new update and upload of Git files.

Program permanent open source update address (for Star):

Github.com/zhaoolee/Wo…

When we open source what we’ve learned over a lifetime to the Internet through decades of daily blog updates, it will surely benefit more like-minded people.