hexo-blogger-xml
Import content/article from blogger to hexo without losing SEO
Feature
- Migrate from blogger to hexo
- Migrate blogger permalink to hexo permalink without losing SEO
- Gulp function supported
Requirements
- Node 12.x 14.x
- Python 2.7 or 3.3
- GCC (node-gyp)
- Typescript (global)
- ts-node (global)
npm config set python /path/python_dir/python
npm i -g node-gyp typescript ts-node
Installation
Using Git Repository (Development)
npm i git+https://github.com/dimaslanjaka/hexo-blogger-xml.git
Using NPM Repository (Production)
npm i hexo-blogger-xml
Setup Hexo _config.yml
permalink: :title.html
pretty_urls:
trailing_html: true
blogger_xml:
site_title: "WMI"
thumbnail: "https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/No_image_available.svg/1024px-No_image_available.svg.png"
callback: "./scripts/post_callback.js"
hostname:
- "webmanajemen.com"
- "git.webmanajemen.com"
output: "source/_posts"
input:
- "../xml/test.xml"
- "./directory/another.xml"
Setup .gitignore to your project
# this is build directory of hexo-blogger-xml
build/hexo-blogger-xml
this plugin run once. If you want to rewrite the posts, you should remove source/hexo-blogger-xml.json
Using GULP Example
view this repo workflow gulp gulpfile.ts
import { gulpCore } from "hexo-blogger-xml";
import path from "path";
gulp.task("blogger", function (done) {
const mainXML = path.resolve("demo/xml/test.xml");
gulpCore({
input: [mainXML],
output: "./src-posts",
hostname: ["webmanajemen.com", "www.webmanajemen.com", "dimaslanjaka.github.io"],
callback: require("./demo/xml/post_callback"),
on: {
finish: (parser) => {
console.log("Blogger gulp finished");
},
},
});
done();
});
run with:
npx gulp blogger
How to export blogger articles/content
How to keep blogger seo to new domain
- Open blogger theme
- Edit HTML, add below codes to
<head></head>
<script type='text/javascript'>
let hostname = "web-manajemen.blogspot.com";
let pathnames = ["/p/search.html", "/p/a.html", "/p/gallery.html", "/p/privacy.html", "/p/tos.html", "/p/proxy-extractor-online.html", "/p/redirect.html", "/p/simple-websocket.html"];
function redirectNow() {
let href = window.location.href;
let url = new URL(href);
url.host = "www.webmanajemen.com";
url.hostname = "www.webmanajemen.com";
let newhref =
url.protocol + "//" + url.host + url.pathname + url.search + url.hash;
window.location.replace(newhref);
}
if (
window.location.host == hostname &&
pathnames.includes(window.location.pathname)
) {
redirectNow();
}
</script>
Preview This Plugin
terminal
homepage
permalink: /2021/09/post-with-description.html
Todo
Source Code
Source Code Compiler
Bash script for migrate blogger to hexo
#!/bin/bash
rm source/_posts/*.md
node_modules/.bin/hexo migrate blogger 'http://blog.meredrica.org/feeds/posts/default?alt=json&max-results=10000'
node_modules/.bin/hexo migrate blogger 'http://jujitsu.westreicher.org/feeds/posts/default?alt=json&max-results=10000'
perl -p -i -e 's/\[!\[]\(http.*?\)](\(http.*?\))/![]\1/g' source/_posts/*
node_modules/.bin/hexo migrate image
perl -p -i -e 's/<.*?>//g' source/_posts/*
perl -0 -p -i -e 's/\n{3,}/\n\n/g' source/_posts/*
rm source/_posts/*.bak
Website using Hexo NodeJS Blogging System
hexo-adsense
hexo-seo
hexo-blogger-xml