哲基尔_config.Yml设置变量为动态值



_config.yml我试图做:

url: "/" + github.repository_name

有可能吗?

你可以!只是和你想的不太一样。

YAML是静态的,所以你不能修改它,但是你可以在你的Liquid模板中使用site.github元数据:

<a href="{{ site.github.url }}"> SITE HOME </a>

额外信息: GitHub在他们的页面构建中提供了很多变量:

下面的示例信息公开给Jekyll模板网站。github名称空间:

{
    "versions": {
        "jekyll": "1.5.1",
        "kramdown": "1.3.1",
        "liquid": "2.5.5",
        "maruku": "0.7.0",
        "rdiscount": "2.1.7",
        "redcarpet": "2.3.0",
        "RedCloth": "4.2.9",
        "jemoji": "0.1.0",
        "jekyll-mentions": "0.0.6",
        "jekyll-redirect-from": "0.3.1",
        "jekyll-sitemap": "0.2.0",
        "github-pages": "18",
        "ruby": "2.1.1"
    },
    "hostname": "github.com",
    "pages_hostname": "github.io",
    "api_url": "https://api.github.com",
    "environment": "dotcom",
    "public_repositories": [ Repository Objects ],
    "organization_members": [ User Objects ],
    "build_revision": "cbd866ebf142088896cbe71422b949de7f864bce",
    "project_title": "metadata-example",
    "project_tagline": "A GitHub Pages site to showcase repository metadata",
    "owner_name": "github",
    "owner_url": "https://github.com/github",
    "owner_gravatar_url": "https://github.com/github.png",
    "repository_url": "https://github.com/github/metadata-example",
    "repository_nwo": "github/metadata-example",
    "repository_name": "metadata-example",
    "zip_url": "https://github.com/github/metadata-example/zipball/gh-pages",
    "tar_url": "https://github.com/github/metadata-example/tarball/gh-pages",
    "clone_url": "https://github.com/github/metadata-example.git",
    "releases_url": "https://github.com/github/metadata-example/releases",
    "issues_url": "https://github.com/github/metadata-example/issues",
    "wiki_url": "https://github.com/github/metadata-example/wiki",
    "language": null,
    "is_user_page": false,
    "is_project_page": true,
    "show_downloads": true,
    "url": "http://username.github.io/metadata-example", // (or the CNAME)
    "contributors": [ User Objects ],
    "releases": [ Release Objects ]
}

最新更新