Pages

Sunday, 13 October 2024

静态博客/网站程序Eleventy

 

Quick Start

Jump to section titled: Quick Start

Eleventy requires Node.js 18. You can check whether or not you have Node installed by running node --version in a Terminal. (Well, wait—what is a Terminal?) If node is not found or it reports a version number below 18, you will need to install Node.js before moving on.

Now we’ll create an index.md Markdown file. You can do this in the text editor of your choice or by running one of these commands in your terminal:

echo '# Heading' > index.md

Run Eleventy using npx, an npm-provided command that is bundled with Node.js.

npx @11ty/eleventy --serve

Eleventy compiles any files in the current directory matching valid file extensions (md is one of many) to the _site output folder. It might look like this:

[11ty] Writing _site/index.html from ./index.md (liquid)
[11ty] Wrote 1 file in 0.03 seconds (v3.0.0)
[11ty] Watching…
[11ty] Server at http://localhost:8080/

The --serve option also starts a local development server. Open up http://localhost:8080/ in your favorite web browser to view your web site.

----------------------------------------------------------

搭建静态博客/网站程序Eleventy

$ git clone https://github.com/11ty/eleventy-base-blog/
$ cd eleventy-base-blog/
$ npm install
$ npx @11ty/eleventy (这个就是生成/更新静态博客的命令。它会在当前目录下生成
_site目录
$ cd _site
$ ls
404.html  blog/  dist/  img/        sitemap.xml
about/    css/   feed/  index.html  tags/
$ python3 -m http.server 3804

在浏览器里访问http://127.0.0.1:3804/,即可看到静态博客的效果。
建立原帖:
cd content/blog/
nano happy-festival.md
cat happy-festival.md
---
title: 快乐的节日
description: 这是一首歌。
date: 2024-10-23T17:30:20
tags: music
---

此处写正文或html codes.

$ cd ../..
npx @11ty/eleventy

项目地址:
https://github.com/11ty/eleventy-base-blog/
演示网站:https://sensational-starship-5ab76e.netlify.app/
-------------
 
搭建Eleventy的theme程序vredeburg
$ git clone https://github.com/daflh/vredeburg  vredeburg-site
$ cd vredeburg-site
$ npm install
$ npm audit fix --force
$ npm run build  (这个就是生成/更新静态博客的命令。它会在当前目录下生成
dist目录
$ cd dist
$ cd ..
$ cd src/posts
$ nano happy-festival.md
$ cat happy-festival.md
显示:
---
title: "快乐的节日"
date: 2024-10-24T16:23:00
tags:
    - life
    - music
---

此处为正文或html codes.
 
$ cd ~/vredeburg-site/
$ npm run build
 
项目地址: https://github.com/daflh/vredeburg
示例博客:https://vocal-fudge-31a567.netlify.app/
  

 





 
 





No comments:

Post a Comment