免费开源Markdown工具如何通过Git或命令行使用开源Markdown工具生成静态网站(如Hugo/Jekyll集成)?
通过Git或命令行使用开源Markdown工具(如Hugo、Jekyll)生成静态网站,通常涉及以下步骤。这些工具将Markdown文件转换为静态HTML,并通过Git进行版本控制或部署。以下是详细指南:
Jekyll安装 需要Ruby环境: ```bash # 安装Ruby和Gem(macOS/Linux) sudo apt install ruby-full # Ubuntu brew install ruby # macOS
# 安装Jekyll gem install bundler jekyll ```
Jekyll ```bash jekyll new my-site cd my-site git init # 可选 bundle install # 安装依赖 ```
# 这是标题
正文内容... ```
Jekyll ```bash bundle exec jekyll serve ``` 访问 `http://localhost:4000`。
自动化部署(推荐) GitHub Actions:创建`.github/workflows/deploy.yml`自动构建和部署。 Hugo示例: ```yaml name: Deploy Hugo on: [push] jobs: build: runs-on: ubuntu-latest steps: uses: actions/checkout@v2 uses: peaceiris/actions-hugo@v2 with: hugo-version: "latest" run: hugo --minify name: Deploy uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./public ``` Jekyll示例: ```yaml name: Deploy Jekyll on: [push] jobs: build: runs-on: ubuntu-latest steps: uses: actions/checkout@v2 uses: ruby/setup-ruby@v1 with: ruby-version: "3.0" run: bundle install run: bundle exec jekyll build name: Deploy uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./_site ```
通过以上步骤,你可以完全通过命令行和Git管理Markdown内容并生成静态网站,无需依赖图形界面。
END
云服务器活动(最新)

扫码添加站长好友
文章投稿、业务合作、咨询等
技术交流、问题反馈等