guimaizi’s blog

Hexo转Hugo

hexo真的是太辣鸡了,生成一次文章好几分钟…… 然后搜了搜发现了hugo 这个玩意, 然后格式不兼容…..就写了下面这个脚本…..

# coding: utf-8
import os
log_path='/Users/guimaizi/blog/content/posts/'
for root, dirs, files in os.walk(log_path):
    log_path_dict = dict()
    for filename in files:
        if '.md' in filename:
            print(filename)
            with open('/Users/guimaizi/blog/content/posts/%s'%filename, 'r+') as f:
                content = f.read()        
                f.seek(0, 0)
                data='''---
title: "从前"
date: 2020-06-06T22:23:20+08:00
draft: true
---
'''
                f.write(data+'\n'+content)

然后title都变成"从前”…..反正我能接受…..你们随意

常用命令:

hugo new article/hexo-hugo.md

hugo -D