Knowledge Base

¿Qué es esto?

Hexo: Instalación

16/12/2016 - 18/12/2018 -  Comentarios - Hexo

Requisitos:

- Node.js

- Git

Si ya lo tenemos instalado debemos ejecutar

npm install -g hexo-cli

Nos devolverá la siguiente salida:

npm WARN optional dep failed, continuing fsevents@1.0.15

/

> hexo-util@0.6.0 postinstall C:\Users\Toni\AppData\Roaming\npm\node_modules\hexo-cli\node_modules\hexo-util

> npm run build:highlight

|

> hexo-util@0.6.0 build:highlight C:\Users\Toni\AppData\Roaming\npm\node_modules\hexo-cli\node_modules\hexo-util

> node scripts/build_highlight_alias.js > highlight_alias.json

> dtrace-provider@0.8.0 install C:\Users\Toni\AppData\Roaming\npm\node_modules\hexo-cli\node_modules\hexo-log\node_modules\bunyan\node_modules\dtrace-provider

> node scripts/install.js

C:\Users\Toni\AppData\Roaming\npm\hexo -> C:\Users\Toni\AppData\Roaming\npm\node_modules\hexo-cli\bin\hexo

hexo-cli@1.0.2 C:\Users\Toni\AppData\Roaming\npm\node_modules\hexo-cli

├── abbrev@1.0.9

├── object-assign@4.1.0

├── minimist@1.2.0

├── tildify@1.2.0 (os-homedir@1.0.2)

├── bluebird@3.4.6

├── chalk@1.1.3 (escape-string-regexp@1.0.5, supports-color@2.0.0, ansi-styles@2.2.1, strip-ansi@3.0.1, has-ansi@2.0.0)

├── hexo-fs@0.1.6 (escape-string-regexp@1.0.5, graceful-fs@4.1.11, chokidar@1.6.1)

├── hexo-util@0.6.0 (striptags@2.1.1, html-entities@1.2.0, camel-case@3.0.0, cross-spawn@4.0.2, highlight.js@9.9.0)

└── hexo-log@0.1.2 (bunyan@1.8.5)

Instalamos el servidor:

npm install hexo-server -g

Nos devolverá una salida como la que sigue:

hexo-server@0.2.0 C:\Users\Toni\AppData\Roaming\npm\node_modules\hexo-server

├── object-assign@4.1.0

├── mime@1.3.4

├── chalk@1.1.3 (ansi-styles@2.2.1, escape-string-regexp@1.0.5, supports-color@2.0.0, has-ansi@2.0.0, strip-ansi@3.0.1)

├── bluebird@3.4.6

├── opn@4.0.2 (pinkie-promise@2.0.1)

├── morgan@1.7.0 (on-headers@1.0.1, basic-auth@1.0.4, depd@1.1.0, on-finished@2.3.0, debug@2.2.0)

├── connect@3.5.0 (parseurl@1.3.1, utils-merge@1.0.0, debug@2.2.0, finalhandler@0.5.0)

├── compression@1.6.2 (on-headers@1.0.1, vary@1.1.0, bytes@2.3.0, debug@2.2.0, compressible@2.0.9, accepts@1.3.3)

└── serve-static@1.11.1 (escape-html@1.0.3, parseurl@1.3.1, encodeurl@1.0.1, send@0.14.1)

hexo init hexo_blog

Nos mostrará una salida similar a la que sigue:

INFO  Cloning hexo-starter to C:\static_site_generators\hexotest\hexo_blog

Cloning into 'C:\static_site_generators\hexotest\hexo_blog'...

remote: Counting objects: 53, done.

remote: Total 53 (delta 0), reused 0 (delta 0), pack-reused 53

Unpacking objects: 100% (53/53), done.

Checking connectivity... done.

Submodule 'themes/landscape' (https://github.com/hexojs/hexo-theme-landscape.git) registered for path 'themes/landscape'

Cloning into 'themes/landscape'...

remote: Counting objects: 756, done.

remote: Compressing objects: 100% (5/5), done.

remote: Total 756 (delta 0), reused 0 (delta 0), pack-reused 751 eceiving objects:  90% (681/7

Receiving objects: 100% (756/756), 2.53 MiB | 1.12 MiB/s, done.

Resolving deltas: 100% (385/385), done.

Checking connectivity... done.

Submodule path 'themes/landscape': checked out 'decdc2d9956776cbe95420ae94bac87e22468d38'

INFO  Install dependencies

npm WARN deprecated swig@1.4.2: This package is no longer maintained

npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue

npm WARN optional dep failed, continuing fsevents@1.0.15

npm WARN optional dep failed, continuing fsevents@1.0.15

> hexo-util@0.6.0 postinstall C:\static_site_generators\hexotest\hexo_blog\node_modules\hexo-renderer-marked\node_modules\hexo-util

> npm run build:highlight

\

> hexo-util@0.6.0 build:highlight C:\static_site_generators\hexotest\hexo_blog\node_modules\hexo-renderer-marked\node_modules\hexo-util

> node scripts/build_highlight_alias.js > highlight_alias.json

> dtrace-provider@0.8.0 install C:\static_site_generators\hexotest\hexo_blog\node_modules\hexo\node_modules\hexo-log\node_modules\bunyan\node_modules\dtrace-provider

> node scripts/install.js

> hexo-util@0.6.0 postinstall C:\static_site_generators\hexotest\hexo_blog\node_modules\hexo\node_modules\hexo-util

> npm run build:highlight

-

> hexo-util@0.6.0 build:highlight C:\static_site_generators\hexotest\hexo_blog\node_modules\hexo\node_modules\hexo-util

> node scripts/build_highlight_alias.js > highlight_alias.json

hexo-generator-index@0.2.0 node_modules\hexo-generator-index

├── object-assign@4.1.0

└── hexo-pagination@0.0.2 (utils-merge@1.0.0)

hexo-generator-tag@0.2.0 node_modules\hexo-generator-tag

├── object-assign@4.1.0

└── hexo-pagination@0.0.2 (utils-merge@1.0.0)

hexo-generator-category@0.1.3 node_modules\hexo-generator-category

├── object-assign@2.1.1

└── hexo-pagination@0.0.2 (utils-merge@1.0.0)

hexo-generator-archive@0.1.4 node_modules\hexo-generator-archive

├── object-assign@2.1.1

└── hexo-pagination@0.0.2 (utils-merge@1.0.0)

hexo-renderer-ejs@0.2.0 node_modules\hexo-renderer-ejs

├── object-assign@4.1.0

└── ejs@1.0.0

hexo-server@0.2.0 node_modules\hexo-server

├── object-assign@4.1.0

├── mime@1.3.4

├── chalk@1.1.3 (escape-string-regexp@1.0.5, supports-color@2.0.0, ansi-styles@2.2.1, strip-ansi@3.0.1, has-ansi@2.0.0)

├── opn@4.0.2 (pinkie-promise@2.0.1)

├── morgan@1.7.0 (on-headers@1.0.1, basic-auth@1.0.4, depd@1.1.0, on-finished@2.3.0, debug@2.2.0)

├── bluebird@3.4.6

├── connect@3.5.0 (utils-merge@1.0.0, parseurl@1.3.1, debug@2.2.0, finalhandler@0.5.0)

├── compression@1.6.2 (on-headers@1.0.1, vary@1.1.0, bytes@2.3.0, compressible@2.0.9, debug@2.2.0, accepts@1.3.3)

└── serve-static@1.11.1 (escape-html@1.0.3, encodeurl@1.0.1, parseurl@1.3.1, send@0.14.1)

hexo-renderer-stylus@0.3.1 node_modules\hexo-renderer-stylus

├── stylus@0.53.0 (css-parse@1.7.0, debug@2.4.4, mkdirp@0.5.1, source-map@0.1.43, sax@0.5.8, glob@3.2.11)

└── nib@1.1.2 (stylus@0.54.5)

hexo-renderer-marked@0.2.11 node_modules\hexo-renderer-marked

├── object-assign@4.1.0

├── marked@0.3.6

├── strip-indent@1.0.1 (get-stdin@4.0.1)

└── hexo-util@0.6.0 (striptags@2.1.1, html-entities@1.2.0, camel-case@3.0.0, bluebird@3.4.6, cross-spawn@4.0.2, highlight.js@9.9.0)

hexo@3.2.2 node_modules\hexo

├── abbrev@1.0.9

├── pretty-hrtime@1.0.3

├── hexo-front-matter@0.2.3

├── archy@1.0.0

├── titlecase@1.1.2

├── text-table@0.2.0

├── strip-indent@1.0.1 (get-stdin@4.0.1)

├── tildify@1.2.0 (os-homedir@1.0.2)

├── chalk@1.1.3 (escape-string-regexp@1.0.5, ansi-styles@2.2.1, supports-color@2.0.0, strip-ansi@3.0.1, has-ansi@2.0.0)

├── minimatch@3.0.3 (brace-expansion@1.1.6)

├── hexo-i18n@0.2.1 (sprintf-js@1.0.3)

├── bluebird@3.4.6

├── moment-timezone@0.5.10

├── swig-extras@0.0.1 (markdown@0.5.0)

├── js-yaml@3.7.0 (esprima@2.7.3, argparse@1.0.9)

├── hexo-fs@0.1.6 (escape-string-regexp@1.0.5, graceful-fs@4.1.11, chokidar@1.6.1)

├── hexo-cli@1.0.2 (object-assign@4.1.0, minimist@1.2.0)

├── swig@1.4.2 (optimist@0.6.1, uglify-js@2.4.24)

├── nunjucks@2.5.2 (asap@2.0.5, yargs@3.32.0, chokidar@1.6.1)

├── hexo-log@0.1.2 (bunyan@1.8.5)

├── moment@2.13.0

├── cheerio@0.20.0 (entities@1.1.1, dom-serializer@0.1.0, css-select@1.2.0, htmlparser2@3.8.3, jsdom@7.2.2)

├── warehouse@2.2.0 (graceful-fs@4.1.11, is-plain-object@2.0.1, JSONStream@1.3.0, cuid@1.3.8)

├── lodash@4.17.2

└── hexo-util@0.6.0 (striptags@2.1.1, html-entities@1.2.0, camel-case@3.0.0, cross-spawn@4.0.2, highlight.js@9.9.0)

INFO  Start blogging with Hexo!

Nos habrá creado el directorio hexo_blog con todos los ficheros. Nos movemos a hexo_blog y ejecutamos:

npm install

No nos devolverá nada, eso es que ha ido bien.

Abrimos el fichero _config.yml y vemos lo que contiene, es el fichero de configuración general del sitio donde podemos especificar el título y otras propiedades:

# Hexo Configuration

## Docs: https://hexo.io/docs/configuration.html

## Source: https://github.com/hexojs/hexo/

# Site

title: Hexo

subtitle:

description:

author: John Doe

language:

timezone:

# URL

## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'

url: http://yoursite.com

root: /

permalink: :year/:month/:day/:title/

permalink_defaults:

# Directory

source_dir: source

public_dir: public

tag_dir: tags

archive_dir: archives

category_dir: categories

code_dir: downloads/code

i18n_dir: :lang

skip_render:

# Writing

new_post_name: :title.md # File name of new posts

default_layout: post

titlecase: false # Transform title into titlecase

external_link: true # Open external links in new tab

filename_case: 0

render_drafts: false

post_asset_folder: false

relative_link: false

future: true

highlight:

  enable: true

  line_number: true

  auto_detect: false

  tab_replace:

# Category & Tag

default_category: uncategorized

category_map:

tag_map:

# Date / Time format

## Hexo uses Moment.js to parse and display date

## You can customize the date format as defined in

## http://momentjs.com/docs/#/displaying/format/

date_format: YYYY-MM-DD

time_format: HH:mm:ss

# Pagination

## Set per_page to 0 to disable pagination

per_page: 10

pagination_dir: page

# Extensions

## Plugins: https://hexo.io/plugins/

## Themes: https://hexo.io/themes/

theme: landscape

# Deployment

## Docs: https://hexo.io/docs/deployment.html

deploy:

  type:

 

Ahora crearemos nuestro primer post. Para ello ejecutamos:

hexo new first-post

Eso nos habrá creado un fichero en el directorio:

source\_posts\first-post.md

Los posts necesitan metadatos, abrimos ese fichero y sustituimos su contenido por esto:

title: DigitalOcean's First Post

tags:

  - Test

  - Blog

categories:

  - Hexo

comments: true

date: 2015-12-31 00:00:00

---

## Markdown goes here.

**This is our first post!**

Una vez hecho eso, arrancamos el servidor:

hexo server

Acedemos a la dirección que nos dice (http://localhost:4000)  y ya tendremos el blog funcionando