如何使用Hyde生成新内容?

11 投票
2 回答
2096 浏览
提问于 2025-04-17 09:46

我正在开始学习Hyde,并且从Github上克隆了一些用Hyde写的博客。我可以在我的网页浏览器中成功生成这些示例博客,并在本地运行它们;但是,我就是搞不清楚怎么生成新的内容。例如,我该怎么添加一个新的HTML文件或markdown文件,然后把这个文件放到网站上?在文档中没有看到相关的说明。我漏掉了什么吗?我正在使用的示例博客的目录结构是这样的:

---content
    ---about
    ---blog  
---deploy
    ---about
    ---blog
---layout
   ---base.j2
   ---listing.j2
   ---posts.j2
---info.yaml
---site.yaml

有没有人能解释一下怎么添加HTML或markdown文件,并让它们在网站上显示?

2 个回答

3

我写了一个叫做Ghorg的项目,它提供了一个命令行工具,可以帮助你管理一系列的org-mode博客文章,并把它们发布成html格式到你的hyde网站上,同时还能调用hyde的生成和发布功能。这个工具主要是为了方便你,不用再去你的网站代码库里操作了。

我觉得,如果一些vim用户或者想要管理文章但不想用org-mode发布的人,比如想用markdown或者其他格式的人(现在这个工具只能在emacs里打开),如果他们愿意帮忙把这个工具做得更通用,那就太好了。

Ghorg: Org for Hyde

    dlacewell@scarf$ ghorg -h
    usage: ghorg [-h] [-b] [-p] [-s SITE] [--config CONFIG] [-l] [-n [N]] [-P]
                 [-U] [-e] [-t TEMPLATE] [-D]
                 [title [title ...]]

    Manage your Ghorg blog.

    positional arguments:
      title                 all arguments will be joined with hyphen for filename
                            `ghorg post title' => `2012-01-12-post-title.org'

    optional arguments:
       h, --help            show this help message and exit
       b, --build           Perform configured Hyde build step.
       p, --publish         Perform configured Hyde publishing step. (implies -b/--        build)
       s SITE, --site SITE  Path to the root of the Hyde site.
       config CONFIG        Filename of Hyde configuration for building.
       l, --list            List previous posts (-n to change count).
       n [N]                Change number of posts listed (default:5).
       P                    Set post as published.
       U                    Set post as unpublished.
       e                    Mix with -P/-U to edit while changing publishing
                            status.
       t TEMPLATE           Location of template for new posts.
       D                    Delete existing post.        
10

Hyde没有直接创建新文件的命令。你可以在自己喜欢的编辑器里创建文件,然后把它保存在正确的文件夹里。

比如说,如果你想要一个博客文章的链接是这个:

http://localhost:8080/blog/2012/01/05/a-new-post,

你需要按照以下步骤操作:

  1. 在你的内容文件夹下创建一个目录 blog/2010/01/05
  2. 用文本编辑器写你的文章
  3. 把文件保存在你在第一步创建的目录里
  4. 当你运行 hyde genhyde serve 时,你会看到这个文件出现在那个链接上

撰写回答