Month: December 2021

Learning – Hexo – Static Site Generator

Learning - Hexo - Static Site Generator

Installation

Install NodeJS and git.

node -v
git version

Install Hexo

npm install -g hexo-cli
hexo -v

Init project

hexo init ga-hexo

This will create a folder called ga-hexo.

Run

cd ga-hexo
hexo server

The server will be run as http://localhost:4000.

Directories

node_modules - used by NodeJS
scaffolds - content templates
source - content folder
source/_post - the posts
themes - themes used
themes/landscape - default theme
_config.yml - define default theme, etc.
.gitignore
db.json
package.json - used by NodeJS package

Write content

Create post

Posts are written in source/_post.

cd ga-hexo
hexo new <page_name>

This will create a file source/_post/<page_name>.md

Create draft

hexo new draft <page_name>

This will create a file source/_draft/<page_name>.md. To show draft in hexo server, run following command

hexo server --draft

Publish draft

hexo publish <page_name>

Create page

hexo new page <page_name>

This will create a folder with index.html file source/<page_name>/index.md. To show page in hexo server, access URL http://localhost:4000/<page_name>/

Default type of page

The default layout can be found in _config.yml file as below

default_layout: post

If modify it as below,

default_layout: draft

Then the following command will create draft

hexo new <page_name>

Front Matter

Can be YAML or JSON

title: A's Title
date: 2017-09-14 15:11:10
tags: [ Tag1, Tag2, Tag3 ]

Scaffolds

In scaffolds folder, has 3 files as template, draft.md, page.md and post.md.

For example the post.md file.

---
title: {{ title }}
date: {{ date }}
tags:
---

Default content

Custom scaffold file

For example scaffolds/giraffee.md

title: {{ title }}
date: {{ date }}
layout: {{ layout }}

Following command

hexo new griaffe f

Will create following file

title: f
date: 2017-09-14 15:11:10
layout: griaffe

Tags & Categories

Tags

tags: [ Tag1, Tag2, Tag3 ]

The page will be

http://localhost:4000/tags/Tag1/

Categories

Categories:
- [Cat1, Cat1.1]
- [Cat2]
- [Cat3]

Tag Plugins

{% codeblock lang:javascript %}
  alert("Hello world");
  var myVar = "Hello World";
{% endcodeblock %}
{% youtuble hY7m5jjJ9mM %}

Asset Folders

The asset folders are static file folders.

To use asset folders, set following line in _config.yml file.

post_asset_folder: true

When run following command, source/_posts/a.md and source/_posts/a/ are created.

hexo new a

To use asset, following statement can be used in markdown file

{% asset_img hexo.jpg Hexo Logo %}

Note: Hexo Logo is the title of image.

To link to asset, use following line

{% asset_link hexo.jpg Hexo Logo %}

To use image path, use following line

{% asset_path hexo.jpg %}

Theme

Install theme

Themes can be downloaded from https://hexo.io/themes/index.html.

Then change _config.yml file as below

theme: alpha-dust

Restart the hexo server.

Create own theme

  • Create folder themes/ga-theme

  • Create file themes/ga-theme/config.yml

  • Create folders

themes/ga-theme/languages
themes/ga-theme/layout
themes/ga-theme/scripts
themes/ga-theme/source
  • Modify _config.yml file
theme: ga-theme
  • Restart hexo server

A blank page will be displayed.

Layout

layout.ejs

Layout is in themes/ga-theme/layout.

  • Create a file called layout.ejs in layout folder.
<html>
...
<body>
  This is the layout.ejs file
  <br>
  <%- body %>
  <br>
  This is the layout.ejs file
</body>
</html>

index.ejs

  • Create another file called index.ejs in layout folder.
This is a index.ejs file.

Then the output will be as follow for all index files, such as http://localhost:4000/, http://localhost:4000/a/, http://localhost:4000/2017/09/13/a/, etc.

This is the layout.ejs file
This is a index.ejs file.
This is the layout.ejs file

So all the pages will use layout.ejs file. And the <%- body %> will be replaced by actual ejs file. In above case, it is index.ejs file.

post.ejs

Create a file called themes/ga-theme/layout/post.ejs

<h1>This is a post</h1>

This will be used for all posts.

page.ejs

Create a file called themes/ga-theme/layout/page.ejs, this will impact all pages.

<h1>This is a page</h1>

tag.ejs

<h1>This is a tag</h1>

category.ejs

Partials

  • Create a folder themes/layout/partial

  • Then create a header.ejs in partial folder.

<h1><%= title %></h1>
<hr> <br>
  • In layer.ejs file
<html>
...
<body>
  <%- partial('partial/header', {title: 'hello world'}) %>
  <br>
  <%- body %>
  <br>
  Footer
</body>
</html>

Variables

Access front matter variable inside layout. For example, in post.ejs

<h1><%- page.title %></h1>
<p><%- page.date %></p>
<hr>
<%- page.content %>

The variables can be found in https://hexo.io/docs/variables.html

Custom variable

<%- page.author %>

If statement

<% if (page.author == "Mike") { %>
  Mike is the author, he's the best
<% } else { %>
  this author sucks
<% } %>

For Loops

<% site.posts.forEach(function(post) { %>
  <li><a href="<%- post.path %>"<%- post.title %></a></li>
  <br>
<% }) %>

Helper

Helpers are small functions.

<%- trim('    This is my string   ') %>
<%- titlecase('This is my string') %>
<%- date(Date.now(), 'YYYY/M/D') %>
<%- date(Date.now(), 'h:mm:ss a') %>

Helps can be found in https://hexo.io/docs/helpers.html.

Data Files

Create folder source/_data, and data file can be JSON or YAML file. Such as myData.yml

var1: "Var1's Value"
var2: "Var2's Value"
var3: "Var3's Value"

In template, such as index.ejs

<%- site.data.myData.var1 %> <br>
<%- site.data.myData.var2 %> <br>
<% for (var value in site.data.myData) { %>
  <%- value %> <br>
<% } %>
<br>
<% for (var value in site.data.myData) { %>
  <%- site.data.myData[value] %> <br>
<% } %>

Plugins

Download from https://hexo.io/plugins/.

Normally, use npm install to install plugin. For example,

npm install hexo-admin

After installed, go to _config.yml, make sure that plugin is listed in dependencies.

Generating Site

Run following command to generate website

hexo generate

The site will be created in public folder.

References

Hexo - Static Site Generator

iSCSI service failed after do-release-update

iSCSI service failed after do-release-update

The issue was caused by missing iscsi driver.

Errors

  • iscsid.service

Got following error

Oct 28 16:45:03 ubuntupi iscsid[6813]: can not create NETLINK_ISCSI socket [Protocol not supported]
  • iscsid.socket
     Active: failed (Result: service-start-limit-hit) since Thu 2021-10-28 16:40:07 +08; 1min 30s ago
  • depmod -a

Don't have iscsi module loaded

  • Error in dmesg
open-iscsi.service - Login to default iSCSI targets

    Process: 2333 ExecStart=/sbin/iscsiadm -m node --loginall=automatic (code=exited, status=21)

Terminology index – a list of bike part names and cycling concepts (Cache)

Terminology index - a list of bike part names and cycling concepts (Cache)

This is a cached page of https://bicycles.stackexchange.com/questions/244/terminology-index-a-list-of-bike-part-names-and-cycling-concepts.

Page Cached

There's a handy reference at the Park Tool Co. website, a bike repair map; it's a diagram of a bike with all the parts labeled, and is very handy! At the moment, the diagram is up at parktool.com/blog/repair-help. (They've changed the URL in the past, so this link may break.)

A road bike has the following parts (source):

bicycle_parts_labeled.jpg

A mountain bike has the following parts (source):

850px-Bicycle_diagram-en.svg_.png


Edit: This page is meant to identify what things or concepts are (as per this thread in meta). If you want to recommend an accessory or a specific product you've found handy, please use the accessories page.


Contents
Axle Axle Nuts
BCD (Bolt Circle Diameter)
Bearing
Belt Drive
Bidon/Bottle
Bonk/Bonking
Bottle Cage / Bottle Holder
Bottom Bracket
Boom/Boom Tube
Brazed Frame
Brifter
BSD (Bead Seat Diameter)
BSO/Bike-Shaped-Object
Cable Pull
Cable Stretcher
Cadence
Cassette
Chain
Chain Gauge
Chain Guard/Cover
Chain Tool
Chain Tug/Chain Tensioner
Chainstay Length
Chainsuck
Chamois
Clipless Pedals
Coaster Brake (foot brake / pedal brake)
Crank
Derailleur
Derailer Hanger/Derailleur Ranger
Direct Drive
Disk/Disc Brake
Disc Hub
Door Zone
Dropout
Dropper Post
Dunlop Valve
e
Engine/Motor
Electronic shifting
Eccentric
Fender/Mudguard/Mudflaps
Fixed-Gear
Flip-Flop Hub
Folding Bike
Frame
Frame Sizing
Gear Inches Groupset
Handlebars
Headset
Hose Clamp aka Jubilee Clip
Hub
Hub Skewer
Internally-Geared Hub
j
Keel Tube
Lawyer lips/lawyer tabs
Lateral Tube
LBS/Local Bike Shop
Lights
Luggage Carrier/Rack
Lugged Frame
Master Link
MIPS
Mixte
Mountain Bike
n
Noodle
o
Over Locknut Dimension or OLD
Pannier
Play
Power Meter
Presta Valve/Presta Tube
Pump Peg
Q-Factor Quick-Release
Recumbent Cycles
REI (Recreational Equipment Inc)
Rim
Rim Tape
Rim Brakes, e.g. cantilever, dual pivot, V-brakes
Saddle
Saddlebag
Schrader Valve/ Schrader Tube
Shaft Drive
Single-speed
Skewer
Spider
Spoke
Stay, Mudguard/fender
Stem
Suspension Fork/Rear Shock
Through/Thru Axle
Tire, Clincher
Tire, Tubeless
Tire, Tubular
Tire, Solid/airless/runflat
Tire Boot
Tire Clearance
Tire Lever/Tire Iron
Tire Saver
Tire Sealant
Tolerances
Track Pump/Floor Pump
Triathalon Bars/Triathlon Bars
u
U-Brake
V-Brake
Velomobile
Welded Frame
x
y
z

References

Terminology index - a list of bike part names and cycling concepts