New Hexo Blog
This blog has migrated to using the Hexo static site generator.
I have pulled my previous posts form Tumblr and placing them here. Trying to store all my content in a simple markdown format that wil be easy to port in the future.
There are a lot of optoins out there, but Hexo seems to be working okay so far.
A few issues so far are:
- Line breaks on every new line
- URL format and post file format
- Importing old posts from Tumblr
- Next steps
Line Breaks
I am used to github/bitbucket new lines where If I wrap the md file after 80 chars or whatever width, is that the processing engine will join the next line up automatically. The default in Hexo is to act every new line as a new paragraph regardless of how many (or none) spaces are left at the end.
Please see: https://github.com/hexojs/hexo-renderer-marked
To change the behaviour the _config.yml
needs to be changed with:
marked:
gfm: true
pedantic: false
breaks: true
smartLists: true
smartypants: true
modifyAnchors: 0
autolink: true
sanitizeUrl: false
headerIds: true
prependRoot: false
external_link:
enable: false
exclude: []
nofollow: false
I have left this on default so far, and let my text editor word wrap. This may be something for me to look into the future.
URL and Titles
You can configure _config.yml
to help format file names when you create a new post with the command:
foo@bar:~$ hexo new post "New Hexo Blog"
This will automatically create a blank file at _posts\New-Hexo-Blog.md
. I typically try to organise any updated data with the date in their file name if possible. Preferably in a format like YYYY-MM-DD
Rather they manually add the date into the Title when adding the post command, you can set this again in the _config.yml
file.
new_post_name: :year/:month-:day-:title.md # File name of new posts
I actually did it one step further and had a directory for each year. So it would save there being 100s or 1000s of files in one directory. This may be wishful thinking for this blog. But the organisation pleases me.
The problem occurs when you publish this post and you end up with a URL of the following: /2020/06/06/2020-06-06-New-Hexo-Blog
. It puts both the time stamp in the base URL and copies the file name as the title. It does not use the title in the .md
file that removes the time stamp name.
I originally had the following in my _config.yml
file:
permalink: :year/:month/:day/:title/
Replacing :title
with :post_title
and then restarting the hexo server for settings to take effect. I get the following url /2020/06/06/new-hexo-blog/
permalink: :year/:month/:day/:post_title/
I originally had the above set to :post-title
as a typo and it set is as undefinded-title. Which I am not sure what caused that behaviour rather than throwing up a config error. I guess :post
was not defined in the JS scope and set it as undefined
in JS fasion and appended the remaining ‘-title’ on the end. Always the scary part of JS where it just tries its best to figuire something out and move on silently with crappy data.
Tumblr Import
The importing of tumblr posts was done with jekyll
. I found installing Ruby and running not so straight forward. This was due to my present laptop not having up-to-date developer tools.
foo@bar:~$ lsb_release -a
No LSB modules are available.
Distributor ID: LinuxMint
Description: Linux Mint 17.3 Rosa
Release: 17.3
Codename: rosa
Linux Mint was a LTS eddition released in December 2015 and out of support in 2019. It is now 2020! I managed to get a suported Ruby/Gem tools installed and ran:
foo@bar:~$ ruby -r rubygems -e 'require "jekyll-import";
JekyllImport::Importers::Tumblr.run({
"url" => "http://blog.x0r.eu",
"format" => "md", # or "md"
"grab_images" => true, # whether to download images as well.
"add_highlights" => true, # whether to wrap code blocks (indented 4 spaces) in a Liquid "highlight" tag
"rewrite_urls" => true # whether to write pages that redirect from the old Tumblr paths to the new Jekyll paths
})'
I was orignally join to use jekyll
, but was fighting with the tools a little. Then tried mkdocs
this was promising but appeared to be more for project documentation. Shame as it is Python and does templating on the Jinja
engine which I have experience in. In the end hexo
worked as I appeared to have the Node 10 on this machine already and installed and ran without much issue. And the documentation seems to be easy to use so far.
Next Steps
Next steps would be for me to document how to do basic management of the hexo tools, starting from how to set them up, and add posts this will likely be a single pager.
I also would like to change the theme a little and make it more individual. I will probably add my own photos on to this or carefully curate the correct open CC licenced photos.