【问题标题】:Using haml for post files with middleman blog使用 haml 通过中间人博客发布文件
【发布时间】:2016-03-14 00:07:12
【问题描述】:

我有一个 Middleman 博客,其中包含源/期刊中的帖子文件。

我的博客配置:

activate :blog do |blog|
  # set options on blog
  blog.prefix = "journal"
  blog.permalink = "{year}-{month}-{day}-{title}.html.haml"
  blog.sources = "{title}.html.haml"
  blog.layout = "journal_layout"
end

还有一个位于 source/journal/2015-12-02-hello-world.html.haml 的帖子文件

\---
title: Hello World
date: 2015-12-02
category: Photography
\---

%article
  %h1 Hello World
  %p Denver, Colorado :: December 2nd, 2015
  %p Lore ipsum dolar

我可以使用直接网址打开页面,但帖子没有注册:

- blog.articles[0...5].each do |article|
  %article
    %h2= link_to article.title, article.url

...frontmatter 只是在页面顶部显示为纯文本。

非常感谢您的宝贵时间。

更新!

博客配置应该是:

activate :blog do |blog|
  # set options on blog
  blog.prefix = "journal"
  blog.permalink = "{year}-{month}-{day}-{title}.html"
  blog.sources = "{year}-{month}-{day}-{title}.html.haml"
  blog.layout = "journal_layout"
end

以及文章HAML文件:

---
title: Hello World
date: 2015-12-02
category: Photography
---

%article
  %h1 Hello World
  %p Denver, Colorado :: December 2nd, 2015
  %p Lore ipsum dolar

【问题讨论】:

    标签: haml middleman


    【解决方案1】:

    问题是您包含完整的文件扩展名“.html.haml”,但中间人博客扩展名所期望的是最终(已处理)文件扩展名,即“.html”。

    将您的博客配置更改为以下内容,它应该可以工作:

    activate :blog do |blog|
      # set options on blog
      blog.prefix = "journal"
      blog.permalink = "{year}-{month}-{day}-{title}.html"
      blog.sources = "{title}.html"
      blog.layout = "journal_layout"
    end
    

    【讨论】:

      猜你喜欢
      • 2023-04-10
      • 1970-01-01
      • 1970-01-01
      • 2022-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-08
      • 1970-01-01
      相关资源
      最近更新 更多