From ae4cf09d64892d54a25a993abc5983be93760bd0 Mon Sep 17 00:00:00 2001 From: curben Date: Sun, 23 Sep 2018 10:35:41 +0930 Subject: [PATCH] Update installation guide Suggest to run 'hexo server' for website preview. --- README.md | 2 +- source/_posts/how-to-create-a-hexo-blog.md | 23 ++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 3e60908..356c354 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ The following are the major changes I made from the upstream. - Homepage shows index of posts. - Remove header and footer display (except for `/about` page). - Use the latest version of [jQuery](https://jquery.com/download/), [fancyBox](https://github.com/fancyapps/fancyBox/releases) and [Font Awesome](https://github.com/FortAwesome/Font-Awesome/releases) -- All js and css files are self-hosted. +- All js and css files are self-hosted and [pre-compressed](https://docs.gitlab.com/ee/user/project/pages/introduction.html#serving-compressed-assets). - Remove analytic, comment system and donation links. --- diff --git a/source/_posts/how-to-create-a-hexo-blog.md b/source/_posts/how-to-create-a-hexo-blog.md index 774ca47..dd71226 100644 --- a/source/_posts/how-to-create-a-hexo-blog.md +++ b/source/_posts/how-to-create-a-hexo-blog.md @@ -12,7 +12,6 @@ Create a website/blog (hosted by [GitLab](https://about.gitlab.com/features/page 4. Change project website to a user website. This is so that the website's home page is `.gitlab.io/`, instead of `.gitlab.io/hexo`. Go to `Settings -> General -> Advanced -> Rename repository`. Change the Path to `.gitlab.io`. 5. If you just want to use a similar layout as this blog, or you're not planning to customize it, you don't have to [install](#installation) Hexo. You still need to change the blog's name and favicon though ([how-to](#naming). - Having Hexo makes it easier for you to debug, rather than relying entirely on the GitLab runner. 1. To create a new post (*without* using [Hexo](https://hexo.io/docs/writing)), create a new `.md` in the [source/_posts](source/_posts) folder. 2. Start with the following header/[front-matter](https://hexo.io/docs/front-matter): ``` @@ -27,11 +26,12 @@ Create a website/blog (hosted by [GitLab](https://about.gitlab.com/features/page 6. After you create a new post, the website would be available on `.gitlab.io/` or the link shown on your project `Settings -> Pages`. ## Installation -1. Clone this project to your workstation. Change `` to a preferred name. +1. Having Hexo means you can debug locally, rather than waiting for gitlab runner. You can even run a local server to preview your blog (see step 6 below). +2. Clone this project to your workstation. Change `` to a preferred name. ```bash $ git clone https://gitlab.com/curben/curben.gitlab.io ``` -2. Install Node.js. +3. Install Node.js. ```bash # Installing npm will also install nodejs as dependency. # Ubuntu/Debian @@ -41,19 +41,24 @@ $ sudo yum install npm # Arch Linux $ sudo pacman -S npm ``` -3. Install Hexo and its dependencies (defined in [package.json](package.json)). +4. Install Hexo and its dependencies (defined in [package.json](package.json)). ```bash $ sudo npm install -g hexo-cli $ cd $ npm install ``` -4. Generate static files to check for any error. You should always do this before pushing/merging commits to the `master` branch. +5. Generate static files to check for any error. You should always do this before pushing/merging commits to the `master` branch. ```bash $ hexo generate ``` -5. Commit the changes and push them. The generated `public` and `node_modules` are [ignored](.gitnore), as GitLab runner will generate them by itself. -6. Check the build status by going to your project `CI /CD -> Pipelines`. Due to the limitation of `hexo`, the build will always pass even when error occurred. Check the Jobs log, look for any error in `$ hexo deploy`. -7. If there is no error, the generated website would be available on `.gitlab.io/` or the link shown on your project `Settings -> Pages`. +6. (Optional) Start Hexo server on localhost:4000 to preview the blog. ([more info](https://hexo.io/docs/server)) +```bash +$ npm install hexo-server --save +$ hexo server +``` +7. Commit the changes and push them. The generated `public` and `node_modules` are [ignored](.gitnore), as GitLab runner will generate them by itself. +8. Check the build status by going to your project `CI /CD -> Pipelines`. Due to the limitation of `hexo`, the build will always pass even when error occurred. Check the Jobs log, look for any error in `$ hexo deploy`. +9. If there is no error, the generated website would be available on `.gitlab.io/` or the link shown on your project `Settings -> Pages`. ## Writing 1. Create a new post (using Hexo) @@ -113,5 +118,3 @@ If you don't have any plan to send merge requests to the upstream, you can remov ## Useful links: [Hexo Docs](https://hexo.io/docs/) [GitLab Pages](https://docs.gitlab.com/ee/user/project/pages/index.html) - -