RSS and Sharing Tags in Hexo

Discovering new things is fun.

I鈥檝e grown to love using Hexo for my blog. Writing posts is as easy as creating a new markdown file and writing away. A simple command to build, a little FTP, and a new post is live.

As I鈥檝e been using it, though, some things have been missing. Namely, an RSS feed and sharing meta tags. Recently, I figured out how to do both. I鈥檝e been purposefully not using a pre-built theme for Hexo, preferring to make my own from scratch, and in doing so the blog has missed what might be considered essential features.


RSS was actually very easy to set up. Hexo provides a plugin to generate feeds.

First, install the plugin:

npm install hexo-generator-feed --save

Then configure in your _config.yml file:

  type: rss2
  path: rss.xml
  limit: 10

And that鈥檚 it. A feed file will be generated with each hexo generate.

Sharing Meta Tags

Sharing meta tags are usually pretty annoying to put on a site. Facebook has their own set that they want, and so does Twitter. I think Google+ might need some special ones, too, but no one really cares.

Luckily, Hexo makes it super easy. Add this to your layout in your <head>:

<%- open_graph({ twitter_site: "@_moscardino" }) %>

Boom! Meta tags! Check out the docs on this magic. The function covers everything and pulls the correct fields from your content automatically. Awesome.

Things To do

The blog is still missing some things, of course. I don鈥檛 think it will ever be fully finished (thus is the life of a developer). I think I鈥檓 going to try and tackle pagination next. As I add more posts (this is number 10), it becomes more necessary. I鈥檓 sure I鈥檒l write about it when it happens.