Previously I tried the TOML to/from YAML convert command to successfully turn my YAML based front matter md files to TOML. It’s cool.
I imported my blog using Hugo import command from Wordpress. Since most of my wordpress blog entries and Chinese titled, the exported/imported file names looked weird, something like %e4%b8%ba%e4%bb%80%e4%b9%88%e8%bd.md.
Obviously, such types of file name is not good for reading and recognizing because all the post files are stored in the same directory. I was wondering if the hugo command can provide something like renaming function, such as
hugo rename date-title dest-dir target-dir
and all the md files in the posts dir can be renamed in the format as “2018-02-28-title.md”, or something like this? I think variables inside the front matter such as author, date, title and maybe id can be extracted, and since wordpress can export correct non-english titles, such a renaming can help avoid the weird file names.
I know nothing about programming. So the current solution by my side is, I exported from wordpress the xml files, imported into hugo(as hugo can retain the time zone information, and runs faster), and put these weird coded files to under the Hexo post directory. With the help of a plugin called hexo-console-rename, I turned my md files all to correct names(which by default is 2018-02-28-title.md). Then, I copied all these renamed files back to hugo again, and by using hugo convert toTOML.
Well, it’s almost done.
Also, I was wondering if I may suggest another function that can insert variables into the existing md post files? For example, the exported files contain information such as guid, id, url and etc, but the default generated md files don’t have these. If hugo command has the insert function, that would be great to insert maybe author’s name according to some certain tags.
Hugo insert author[author="ang"] if tags="computer game"
Well, I don’t know if the command should look like this.