<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>hexo ubuntu 20.04 Archives - Linux Windows and android Tutorials</title>
	<atom:link href="https://www.osradar.com/tag/hexo-ubuntu-20-04/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.osradar.com</link>
	<description>tutorials and news and Seurity</description>
	<lastBuildDate>Tue, 05 Jan 2021 16:40:35 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.8.12</generator>
	<item>
		<title>How To  Install and Create a Blog with Hexo On Ubuntu 20.04</title>
		<link>https://www.osradar.com/how-to-install-and-create-a-blog-with-hexo-on-ubuntu-20-04/</link>
					<comments>https://www.osradar.com/how-to-install-and-create-a-blog-with-hexo-on-ubuntu-20-04/#comments</comments>
		
		<dc:creator><![CDATA[sabi]]></dc:creator>
		<pubDate>Tue, 05 Jan 2021 16:40:34 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[hexo linux installation guide]]></category>
		<category><![CDATA[hexo ubuntu 20.04]]></category>
		<category><![CDATA[how to install hexo]]></category>
		<category><![CDATA[how to install hexo on ubuntu 20.04]]></category>
		<category><![CDATA[how to tutorials]]></category>
		<category><![CDATA[Ubuntu 20.04 tutorials]]></category>
		<guid isPermaLink="false">https://www.osradar.com/?p=26448</guid>

					<description><![CDATA[<p>Today we are going to learn that how to install &#38; create a blog with Hexo on Ubuntu 20.04. Hexo is a static blogging platform built on Node.js. With the help of hexo you can write posts in Markdown format. It converts the blog posts into static HTML files with the help of pre-built themes. [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/how-to-install-and-create-a-blog-with-hexo-on-ubuntu-20-04/">How To  Install and Create a Blog with Hexo On Ubuntu 20.04</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Today we are going to learn that <a href="https://www.osradar.com/?p=26448" target="_blank" rel="noreferrer noopener">how to install &amp; create a blog with Hexo on Ubuntu 20.04</a>. Hexo is a static blogging platform built on Node.js. With the help of hexo you can write posts in Markdown format. It converts the blog posts into static HTML files with the help of pre-built themes. It varies from the other blogging softwares as it uses static files instead of loading code again &amp; again when you reload the site. So, here we&#8217;ll see that how to install it on your system.</p>



<h2>Step 1: Update Your System</h2>



<p>As usual we do, update your system to have the latest updates installed.</p>



<pre class="wp-block-verse">sudo apt update -y<br>sudo apt upgrade -y</pre>



<p>Then install the required packages by typing</p>



<pre class="wp-block-verse">sudo apt install git
git config --global user.name <strong>"Your Name"</strong>
git config --global user.email <strong>"youremail@domain.com"</strong></pre>



<p><strong>Note:</strong> Replace your git username, email &amp; domain name.</p>



<h3>Step 2: Configure Firewall on Ubuntu 20.04</h3>



<p>Allow the firewall access by enabling the SSH port. Don&#8217;t forget to enable firewall if you&#8217;re installing it for the first time.</p>



<pre class="wp-block-verse">sudo ufw enable</pre>



<p>Then enable the port 4000 in order to communicate</p>



<pre class="wp-block-verse">sudo ufw allow 4000</pre>



<p>Make sure to allow http, https &amp; then verify the status of firewall.</p>



<pre class="wp-block-verse">sudo ufw allow http<br>sudo ufw allow https<br>sudo ufw status</pre>



<p><strong>Output:</strong></p>



<pre class="wp-block-verse">sabi@Ubuntu20:~$ sudo ufw status
 Status: active
 To                         Action      From
 --                         ------      ----
 4000                       ALLOW       Anywhere                  
 80/tcp                     ALLOW       Anywhere                  
 443/tcp                    ALLOW       Anywhere                  
 4000 (v6)                  ALLOW       Anywhere (v6)             
 80/tcp (v6)                ALLOW       Anywhere (v6)             
 443/tcp (v6)               ALLOW       Anywhere (v6)             
 sabi@Ubuntu20:~$ </pre>



<h3>Step 3: Install Node.js on Ubuntu 20.04</h3>



<p>Hit the below commands to install <a href="https://www.osradar.com/how-to-install-nodejs-on-ubuntu-18-04-lts-linux-mint-19/" target="_blank" rel="noreferrer noopener">node.js on Ubuntu 20.04</a>.</p>



<pre class="wp-block-verse">curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -<br>sudo apt install nodejs</pre>



<p>Verify the installed version</p>



<pre class="wp-block-verse">node --version</pre>



<h3>Step 4: Install Hexo On Ubuntu 20.04</h3>



<p>Fire the below command in your terminal to install Hexo on Ubuntu 20.04</p>



<pre class="wp-block-verse">sudo npm install hexo-cli -g</pre>



<p>Once installed, make a new directory to install Hexo</p>



<pre class="wp-block-verse">sudo mkdir -p /var/www/hexo</pre>



<p>Give it proper permissions</p>



<pre class="wp-block-verse">sudo chown -R $USER:$USER /var/www/hexo<br>sudo chmod -R 755 /var/www/hexo</pre>



<p>Now switch to the hexo directory &amp; initialize it.</p>



<pre class="wp-block-verse">cd /var/www/hexo
hexo init</pre>



<pre class="wp-block-verse">INFO  Cloning hexo-starter https://github.com/hexojs/hexo-starter.git
 INFO  Install dependencies
 added 185 packages from 430 contributors and audited 191 packages in 6.47s
 14 packages are looking for funding
 run npm fund for details
  found 0 vulnerabilities
 INFO  Start blogging with Hexo!</pre>



<p>Finally hit the below command to install hexo</p>



<pre class="wp-block-verse">npm install</pre>



<h3>Step 5: Configure Hexo On Ubuntu 20.04</h3>



<p>Edit the<strong> _config.yml </strong>file</p>



<pre class="wp-block-verse">sudo nano _config.yml</pre>



<p>And then change the name of options according to your needs.</p>



<pre class="wp-block-verse">## Hexo Configuration
##  Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/
 #Site
 title: Hexo
 subtitle: ''
 description: ''
 keywords:
 author: sabi
 language: en
 timezone: ''
 #URL
 If your site is put in a subdirectory, set url as 'http://example.com/child' and root as '/child/'
 url: http://example.com
 root: /
 permalink: :year/:month/:day/:title/
 permalink_defaults:
 pretty_urls:
   trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
   trailing_html: true # Set to false to remove trailing '.html' from permalinks</pre>



<p><strong>Note:</strong> Provide domain name, URL, site title &amp; other required options &amp; do 2 more changes.</p>



<ul><li>change <strong>default_layout</strong> value from post to draft.</li><li>change <strong>post_asset_folder </strong>variable to true.</li></ul>



<h3>Step 6: Install themes For Your Blog</h3>



<p>As hexo comes with the default theme, you can change to your favourite them by the hexo Themes page.</p>



<p>Here we&#8217;ll install Next theme for testing. To install this first switch to the <strong>/var/www/hexo/</strong> directory &amp; download the theme</p>



<pre class="wp-block-verse">cd /var/www/hexo<br>git clone https://github.com/theme-next/hexo-theme-next themes/next</pre>



<p>Once downloaded, edit the <strong>_config.yml</strong> to update your new theme.</p>



<pre class="wp-block-verse">sudo nano _config.yml</pre>



<p>Do the changes to theme variable in order to install new theme</p>



<pre class="wp-block-verse"># Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
 theme: next</pre>



<p>In order to update the theme settings, change the <strong>/var/www/hexo/themes/next/_config.yml</strong> file.</p>



<h3>Step 7: Create Your First Post</h3>



<p>Hit the below command to create your first post.</p>



<pre class="wp-block-verse">hexo new first-post<br>INFO Validating config<br>INFO Created: /var/www/hexo/source/_drafts/first-post.md</pre>



<p>Once created, fire the below command to edit new post.</p>



<pre class="wp-block-verse">sudo nano ./source/_drafts/first-post.md</pre>



<p>Each post should have it&#8217;s own front-master. It constists of title, published date, categories, tags, etc. Update the default details with the accurate one.</p>



<pre class="wp-block-verse">title: sabi's First Post
 tags:
 test
 categories:
 Hexo
 comments: true 
 date: 2021-01-02 00:00:00
 Markdown goes here.
**This is our first post!**</pre>



<p>To place an image in your post add the below command in your post.</p>



<pre class="wp-block-verse">{% asset_img "example.jpg" "This is an example image" %}</pre>



<p>Note: Replace<strong> example.jpg</strong> with your image name &amp; then copy that file to <strong>\source_posts\first-pos</strong>t directory.</p>



<p>Then save &amp; exit the file.</p>



<p>Finally publish the post by typing</p>



<pre class="wp-block-verse">hexo publish first-post</pre>



<h3>Step 8: Installing a Plugin For Hexo</h3>



<p>Get the plugins for hexo from their <a href="https://hexo.io/plugins/" target="_blank" rel="noreferrer noopener nofollow">hexo plugins page</a>. You can install your favourite one according to your needs. Save the plugin by typing</p>



<pre class="wp-block-verse">cd /var/www/hexo<br>npm i hexo-filter-nofollow --save</pre>



<p>Then edit the below file</p>



<pre class="wp-block-verse">sudo nano _config.yml</pre>



<p>Add the below lines at the end of the above file.</p>



<pre class="wp-block-verse">nofollow:<br>enable: true<br>field: site<br>exclude:<br>- 'exclude1.com'<br>- 'exclude2.com<br>enable: To activate the plugin.<br>field: Explain the scope of the plugin.<br>exclude: To exclude domains for nofollow links.</pre>



<h3>Step 9: Testing Hexo Server</h3>



<p>Hit the below command to test the hexo server.</p>



<p>hexo server</p>



<p>Then type IP:4000 in browser &amp; you&#8217;ll see the welcome page with your post created earlier.</p>



<p>Simply hit Ctrl+C to stop the server.</p>



<h3>Step 10: Generate Hexo Static Files</h3>



<p>Hit the below command to generate the static files</p>



<pre class="wp-block-verse">hexo generate</pre>



<p>These files can be found at <strong>/var/www/hexo/public</strong>. From there, you can server them publically. We&#8217;ll use Nginx for this purpose.</p>



<p>Fire the given command to install nginx</p>



<pre class="wp-block-verse">sudo apt install nginx</pre>



<p>Edit the hexo config file</p>



<pre class="wp-block-verse">sudo nano /etc/nginx/sites-available/hexo.conf</pre>



<p>Then add the below data into the file.</p>



<pre class="wp-block-verse">server {
     server_name hexo.example.com;
root /var/www/hexo/public; 
index index.html index.htm; 
listen 443 ssl http2; listen [::]:443 ssl http2; 
ssl_certificate /etc/letsencrypt/live/hexo.example.com/fullchain.pem;
 ssl_certificate_key /etc/letsencrypt/live/hexo.example.com/privkey.pem; 
ssl_protocols TLSv1.2 TLSv1.3;
ssl_session_timeout 1d; 
ssl_session_cache shared:MozSSL:10m;  
# about 40000 sessions ssl_session_tickets off; 
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES25&gt;             ssl_prefer_server_ciphers off; 
ssl_dhparam /etc/ssl/certs/dhparam.pem; 
location / { 
    try_files $uri $uri/ =404; 
}
 }
 server {
     if ($host = hexo.example.com) {
         return 301 https://$host$request_uri;
     }
     server_name hexo.example.com;
     listen 80;
     listen [::]:80;
     return 404;
 }</pre>



<p>Then save &amp; exit the file.</p>



<p>Link the config file by typing</p>



<pre class="wp-block-verse">sudo ln -s /etc/nginx/sites-available/hexo.conf /etc/nginx/sites-enabled/</pre>



<p>Next, hit the below command to edit the nginx config file</p>



<pre class="wp-block-verse">sudo nano /etc/nginx/nginx.conf</pre>



<p>Add the given line before the line include <strong>/etc/nginx/conf.d/*.conf</strong></p>



<pre class="wp-block-verse">server_names_hash_bucket_size 64;</pre>



<p>Update the types_hash_max_size value from 2048-4096</p>



<pre class="wp-block-verse">types_hash_max_size 4096;</pre>



<p>Save the file &amp; verify the syntax.</p>



<pre class="wp-block-verse">sudo nginx -t</pre>



<p>And restart nginx</p>



<pre class="wp-block-verse">sudo systemctl restart nginx</pre>



<h3>Step 11: Install SSL For Hexo</h3>



<p>Now, install certbot by typing</p>



<pre class="wp-block-verse">sudo apt install certbot</pre>



<p>Hit the below command to generate the certificates then create a DHParams certificates.</p>



<pre class="wp-block-verse">sudo certbot certonly --standalone -d hexo.yourdomain.com --preferred-challenges http --agree-tos -n -m email@yourdomain.com --keep-until-expiring 
 sudo systemctl start nginx
 sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048</pre>



<p>You can host hexo sites on your server as well as with git,netlify,vercel &amp; many more platforms.</p>



<p>So, this is how you can install &amp; create a Hexo blog on Ubuntu 20.04.</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/how-to-install-and-create-a-blog-with-hexo-on-ubuntu-20-04/">How To  Install and Create a Blog with Hexo On Ubuntu 20.04</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.osradar.com/how-to-install-and-create-a-blog-with-hexo-on-ubuntu-20-04/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
