To get started with Hexo, a static site generator written in Node.js, you can follow these steps:
Installation: First, ensure you have Node.js installed on your machine. Then, install Hexo globally via npm (Node Package Manager) by running the following command in your terminal:
npm install -g hexo-cli
Setup a New Site: Create a new directory for your Hexo project and navigate into it. Then, initialize a new Hexo site:
hexo init myblog
Replace “myblog” with the name you want for your project.
Navigate to Your Project Directory: After initialization is complete, navigate into your project directory:
cd myblog
Start the Server: Start the Hexo server to preview your site locally:
hexo server
This command will start a local server at http://localhost:4000/
. Open this URL in your web browser to see your site.
Write Content: Create new content by using Hexo’s command-line interface. For example, to create a new blog post, you can run:
hexo new "My First Post"
This will create a new Markdown file under source/_posts
directory with the title “My First Post”.
Generate the Site: Once you have written your content, generate the static site by running:
hexo generate
This command will generate the static HTML files for your site in the public
directory.
Deployment: You can deploy your site to various hosting platforms like GitHub Pages, Netlify, or Amazon S3. Configure the deployment settings in your Hexo configuration file (_config.yml
) and then run the deployment command.
For example, to deploy to GitHub Pages, you need to install the Hexo Deployer Git plugin:
npm install hexo-deployer-git --save
Then, configure your _config.yml
file with your GitHub repository information and run:
hexo deploy
This will push your generated site to the specified GitHub repository.
That’s a basic overview to get you started with Hexo. As you get more familiar with Hexo, you can explore its themes, plugins, and other advanced features to customize and enhance your site further.