Tag Archives: blog

How to Solve Hexo init error: bash: hexo: command not found

Project scenario:

in hexo + GitHub blog deployment, set up and register GitHub account and create warehouse in nodejs and git environment, and then start to set up blog

    1. Run NPM install – G hexo install hexo local environment, enter hexo to check whether the hexo command can be run
    1. (1) create a working folder for saving the local blog myblog
    1. (2) initialize the hexo blog project: hexo init
    1. (3) compile the blog system: hexo g
    1. (4) start the local server for preview: hexo s

If hexo is working properly, enter http://localhost:4000/ You can see the initial appearance of the blog


Problem Description:

after installing the local environment and using git bash in windows, the hexo init command cannot be executed, and the following error is reported: </ font>

bash: hexo: command not found

Cause analysis:

it may be that the NPM environment of node is not well configured. You can try to reinstall node and install it in the default path, or it may not be completely installed when installing with git bash


Solution:

method 1: select the folder where you downloaded the note.js, right-click to open it with git bash, and then enter the command
method 2: open the previously created folder (your blog, mine is blog), hold down shift, right-click, select PowerShell option, open the command prompt, and enter the following command:

after that, a new folder blog will be generated in your folder, which is the content to be deployed

After entering NPX hexo server, you can see that a section of address appears: http://localhost:4000 , you can preview it by typing in your browser

Note: it is recommended to use method 1, because if you use method 2 to deploy successfully, you should use NPX command when writing articles later!!!

404 solution for WordPress Chinese tag

One of the common problems in blogs or websites built by WordPress is that the Chinese tag link does not exist. Google Administrator Tool prompt grabs 404 errors. In particular, windows hosts often have Chinese tag link grabbing errors, and Chinese tags cannot be displayed normally. Or Chinese tags can be displayed normally, but 404 errors will appear after clicking the link, which brings great inconvenience to users and is extremely difficult It greatly reduces the friendliness of the website.

How to solve this problem?

First method:

Open WP include/ classes.php (before 3.1) or WP include/class- wp.php (after 3.1 +, hereinafter referred to as the new version) find line 154 (the new version is line 142)

$pathinfo = $_ SERVER['PATH_ INFO';

Replace with:

$pathinfo = mb_ convert_ encoding($_ SERVER['PATH_ INFO'], 'UTF-8', 'GBK');

Find line 159 (the new version is line 147)

$req_ uri = $_ SERVER['REQUEST_ URI'];

Replace with:

$req_ uri = mb_ convert_ encoding($_ SERVER['REQUEST_ URI'], 'UTF-8', 'GBK');

After my personal test, this method can be used, the new version of the statement may be different from the above, but the method is basically the same, the corresponding statement can be replaced.

Second method:

1. Found in the WP includes folder at the root of the site“ rewrite.php ”This document;

2. Back it up“ rewrite.php ”In case of error (we’d better back up the original code before changing the code);

3. Open“ rewrite.php ”We find the following code in the file:

function get_tag_permastruct()
{
   if (isset($this-&gt;tag_structure)) 
  {
    return $this-&gt;tag_structure;
  }
  if (empty($this-&gt;permalink_structure)) 
  { 
    //Change this line
    $this-&gt;tag_structure = '';
    return false;
  }
  if (empty($this-&gt;tag_base))
  $this-&gt;tag_structure = $this-&gt;front . 'tag/';
  else$this-&gt;tag_structure = $this-&gt;tag_base . '/';
  $this-&gt;tag_structure .= '%tag%';
  return $this-&gt;tag_structure;
}

4. Put some of them together

" if (empty($this-&gt;permalink_structure)) { ”

Amend to read

“ if (! empty($this-&gt;permalink_structure)) { ";

Note that there is only a “!” sign in English. After testing, this method is very effective. PS. didn’t find the code in this file directly…

The third method: the final solution to the Chinese tag 404 error is actually ISAPI_ Rewrite pseudo static rules are not well written, which leads to the failure to find the web page file. In fact, just change the rules: the previous tag pseudo static rules

RewriteRule /tag/(.*)$ /index\.php\?tag=$1

Changed rules

RewriteRule /tag/(.*)/$ /index\.php\?tag=$1

I didn’t test this method, so I can’t guarantee its availability. Please back it up before modification!

Third method:

If the above two methods are not feasible, we recommend another method: alias each tag.

Alias is another URL friendly name. It is usually lowercase and can only contain letters, numbers and hyphens.

But for blogs with more than 100 Chinese tags, this method has a huge workload. Use with caution.

This method can link English tags normally, but it works for websites with Chinese tag problems, but it doesn’t work for websites with 404 English tag links.

About WLW (Windows Live Writer): “unable to connect to your log service: invalid server response” solution

The following error occurred while configuring the blog’s WLW (Windows Live Writer) service: “unable to connect to your log service: invalid server response – received response from the log server blogger.getUsersBlogs Method’s response is invalid: invalid response document returned from XMLRPC server. Please try to resolve the problem and try again. ”

Document the solution:

Windows Live Writer (hereinafter referred to as WLW) is a very convenient blog offline editor launched by Microsoft. Recently, I want to use it to update the blog, but there are many problems in the configuration. Please record here for more friends to see.

First of all, to use WLW in WordPress, you must enable the XML-RPC publishing protocol. This protocol is enabled by default in WordPress versions after 3.5. If it is a version before 3.5, you need to find the xml-prc protocol under the “Settings – & gt; composition” menu, and then open it.

After the service is started, configure the parameters according to the regulations and wait for the link. The result is “unable to connect to your log service: invalid response from the server – the response received from the log server is invalid” blogger.getUsersBlogs Method’s response is invalid: invalid response document returned from XMLRPC server. Please try to resolve the problem and try again. ” This is a mistake.

The cause of this problem is very simple – this is due to a bug in WordPress itself. Under UTF-8 encoding, XML RPC returns an incorrect format and lacks three bytes.

Find the reason and solve it

    Step 1: find class- IXR.php The second step is to open and edit the class- IXR.php File, and then find the statement [$length = strlen ($XML);] to replace [$length = strlen ($XML) + 3;], and the problem is solved!

Note: please back up the original file before editing

OK, restart WLW to link. Is that ok?

OK, the problem was solved successfully~~

Sudo: unable to resolve host solution

When using the sudo command of Linux, some people may encounter such a problem: “sudo: can’t parse the host: xxxxx (your host name). I also encounter this problem. I have found a solution on the Internet and share it with you here.

This problem is caused by the hosts file is not well configured, Linux can not resolve to your host address, the solution is as follows:

sudo vim /etc/hosts

VIM is the command of your text editor. If you don’t have VIM in your computer, you can use GEDIT.

After opening the file, the

127.0.1.1  xxxxx

The following XXX is replaced by your computer host name, which is the last string of characters in the error. If not, add it in. If there are many parts of soybean oil, they can be replaced in batches.

Article link: sudo: unable to resolve host solution

Causes and solutions of WordPress media library pictures not showing or showing errors

Recently, I am developing a WordPress Theme – wait theme, but in the process of development, a wonderful problem suddenly appears, the media library pictures are not displayed!! Always show the small circle in loading, and upload images always fail. After struggling for two or three days, I finally found out the problem and quickly wrote it down….

describe

Recently, I am developing a WordPress Theme – wait theme, but in the process of development, a wonderful problem suddenly appears, the media library pictures are not displayed!! Always show the small circle in loading, and upload images always fail. The details are shown in the figure below:

The selection list mode is normal

attempt

After finding this problem, the other work of theme development can only be temporarily stopped and focused on solving this problem.

First go to the Internet search, the results found that the results are the same, what folder permissions, file coding problems, plug-in settings and so on.

However, this is a local test system. No plug-ins are installed and there is no permission problem. The coding format is utf8 without BOM.

It is found that a few netizens have the same problem as me, but no one below gives a solution…..

After the search on the Internet is fruitless, we can only find a solution by ourselves.

explore

First of all, I suspect that my topic function has the same name as the function of WP. So open it upload.php , compare the functions one by one with the functions written by yourself, and find that there is no duplicate name problem, so this option is excluded.

Then check the admin file, no suspicious situation is found.

In the browser debugging window, check the loading and debugging of CSS and JS, and no exception is found.

Finally, there is no way to open the code window, line by line to view the code, also did not find anything suspicious.

It took me two or three days to go back and forth in this way. Until this afternoon, I found the root of the problem~~~~

problem

When looking at the code again this afternoon, I suddenly found such a statement:

The problem lies in this sentence!!!!

Look at the explanation of HTML Declaration on w3school

≪! DOCTYPE & gt; declaration must be the first line of an HTML document, before the & lt; HTML & gt; tag.

≪! DOCTYPE & gt; declaration is not an HTML tag; it is an instruction to the web browser about which HTML version the page is written with.

In HTML 4.01, the & lt;! DOCTYPE & gt; declaration references DTD because HTML 4.01 is based on SGML. DTD specifies the rules of markup language, so that the browser can present the content correctly.

HTML5 is not based on SGML, so there is no need to reference DTD.

Tip: always add a & lt;! DOCTYPE & gt; declaration to an HTML document so that the browser knows the document type.

≪! DOCTYPE & gt; declaration must be the first line of an HTML document, before the & lt; HTML & gt; tag! ≪! DOCTYPE & gt; declaration must be the first line of an HTML document, before the & lt; HTML & gt; tag! ≪! DOCTYPE & gt; declaration must be the first line of an HTML document, before the & lt; HTML & gt; tag!

Three important words~~

Therefore, as long as the above obnoxious sentence is removed, this problem can be solved ~ ~
by removing it

solve

Looking for the source code, I found that there was a reference in my admin file:

At that time, I thought that this sentence would be in the main body of the web page, so I wrote it. But today, I found that no matter where I put it, it will always appear in the first line of the web page!!! WTF!!!

Only by deleting it and writing the CSS code to the file, can the problem be solved successfully~~~~

summary

1. Don’t blindly believe in things on the Internet, do it yourself is the king

2. Debugging a bug starts with the source code.

3. When it comes to problems, be calm and don’t be impatient~~

4. Do it yourself~~~

prospect

Wait theme will be released soon, please look forward to it~~~

Reprint English blogs with source

Reprint English blogs with source

Reprint English blogs with source

Three important words~~


Welcome to my website:

Other English Blogs

++>

Causes and solutions of WordPress media library pictures not showing or showing errors

Solution of U disk content hidden by virus

Recently, I found that I have a virus in my USB flash disk, and the contents of the USB flash disk are hidden. However, when I view the properties, all of them actually occupy the memory. The effect is as shown in the figure. I believe many friends have encountered this kind of problem, so how to solve it?


The figure is as follows:

First of all, check whether the contents of the U disk are cleared or hidden. If it is cleared by a virus, you can only use the recovery tool to recover. But if it’s just hidden, you can use the “tools” button in the menu bar -& gt ; Folder selection -& gt ; see -& gt ; Show hidden folders to show hidden files.

If all the hidden files exist, you can use the following method to remove them.

1. Create a new TXT in the USB flash disk with any name;

2. Enter:

attrib -s -h /s /d

3. Change the suffix to. Bat, and then double-click to run.

You can also pay attention to my personal blog

Other English Blogs

The solution of U disk content hidden by virus

On and off of timer in JS

setInterval()
When a function
is called for a specified period of time:

setInterval(function,time,lang)

function: function to be called or code string to be executed
time: required parameters, every how long to call the function, in milliseconds
lang: optional parameters, running JScript | VBScript | JavaScript
clearInterval()
Means to stop the setInterval timer call function

function getTime() {
        console.log(123);
        if (true) {
            clearInterval(db)
        }
    }

let db = setInterval(getTime, 1000)

setTimeout()
Call a function after a certain time
syntax:

setTimeout(function,time,lang)

Function:
function: required, to be called
time: required, number of milliseconds to wait before executing code
lang: optional, script language: JScript | VBScript | JavaScript