在jekyll构建过程中重命名页面 [英] Rename a page during jekyll build

查看:65
本文介绍了在jekyll构建过程中重命名页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在jekyll build期间将表示为someFancyPage.md的文件重命名为index.md. 但是,该文件需要保留在同一目录中.

I would like to rename a file denoted as someFancyPage.md to index.md during jekyll build. However, the file needs to remain in the same directory.

到目前为止,我尝试了permalink,但是似乎总是将值解释为绝对值.

So far I tried permalink, which however seems to be always interpreting the value as absolute.

我想使用这种行为,因为我创建了一个插件,该插件可以在包含someFancyPage.md的文件夹上执行并具有一定的魔力.

I would like to use this behavior, as I created a plugin, which executes on folders containing someFancyPage.md and does some magic.

推荐答案

我采用的解决方案有效(不太好),而文件名保留为index.md:

The solution I adopted works (it is not really nice) uses information of the front matter while the filename remains index.md:

---
layout: picture-gallery
---

在我的插件中,我现在搜索具有这种布局的页面. 添加一个自定义的前端问题(在我的情况下,使用layout).

In my plugin, I search now for the pages, which have this layout. add a custom front matter (in my case the layout is used).

    def generate(site)
        paginator_directories = Array.new
        pages do |sf|
            #next unless sf.respond_to?(:layout)
            #This is a workaround to check if "layout: picture-gallery" is set.
            next unless File.readlines(sf.path).grep(/picture\-gallery/).size > 0

            paginator_directories.insert(-1, File.dirname(sf.path))
        end

        #Do some really fancy magic here.
   end

这篇关于在jekyll构建过程中重命名页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆