Hexo - Adding Pictures/Graphics

Hexo has a couple of Native Languages. The one that I use is Markdown, which is a dummied down language designed to create webpages. I create a markdown page and hexo will display it as a static webpage.

The problem I wanted to solve is ‘how do I add a picture to a webpage’

Adding pictures requires a plug-in.

Check package.json and see if you have a dependancy named ‘hexo-asset-link’. If the dependencies section does not show this, then you’ll need to install the plugin.

First, Install the plug-in.

1
npm i -s hexo-asset-link

Second, change a parameter in _config.yml

1
post_asset_folder: true

(I changed the parameter called post_asset_folder from False to true)

That’s the basic setup, the next step is to add graphics to a page.

Here’s what you will do.

  • Create a document (for example hexo new draft ‘Jigsaw-Puzzles-101’)
  • Create a folder in the posts folder (for example a folder named ‘Jigsaw-Puzzles-101’)
  • In your draft document add a link where you want to place the picture. ( For example ![Jigsaw Puzzle Graphic](.//Jigsaw-Puzzles-101//Jigsaw-Puzzles-101.jpg) )

Here is more detail

Your document is in the Drafts folder (for example Jigsaw-Puzzles-101.md) and you have graphics in _posts\Jigsaw-Puzzles-101

./Hexo Adding Pictures - initial directory

Your document contains something like this
![Jigsaw Puzzle Graphic](./Jigsaw-Puzzles-101/Jigsaw-Puzzles-101.png)

Hexo Publish will take the ![](x/x.png) structure and create a proper link. So did ![](./x/x.png). Where X should match the name of your document.

./Hexo Adding Pictures - After Publish

Hexo Generate created the x.html, the x\ folder, and copied _posts\x\x.png into the x\ folder

./Hexo Adding Pictures - After Generate