Max Toro
Max Toro

Reputation: 28608

Jekyll _config.yml set variable to dynamic value

In _config.yml I'm trying to do:

url: "/" + github.repository_name

Is it possible?

Upvotes: 0

Views: 773

Answers (1)

user3276552
user3276552

Reputation: 1072

You can! Just not in the exact way you were wondering.

The YAML is static, so you can't modify that, but you can use site.github metadata in your Liquid templates:

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

Extra info: GitHub provides a lot of variables on their page build here:

The following sample information is exposed to Jekyll templates in the site.github namespace:

{
    "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 ]

}

Upvotes: 2

Related Questions