Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project version as variable #187

Open
chraibi opened this issue Dec 21, 2019 · 2 comments
Open

Project version as variable #187

chraibi opened this issue Dec 21, 2019 · 2 comments

Comments

@chraibi
Copy link

chraibi commented Dec 21, 2019

Is it possible to define a variable, say project_version in _config.html

and use it in one of the sidebars as {{site.project_version}}?

I tried this already but it did not render correctly.

Any idea why not?

@MarkWieczorek
Copy link
Contributor

I also would like to automatically update the project verison number that is used in this theme. I found a useful jekyll pluggin that does almost everything I want : jekyll-version-plugin. Once this is installed, you only need to add {% project_version %} to a markdown file and it will replace this with the version tag obtained from the git repository.

However, this does not work in the sidebar of this theme:

entries:
- title: sidebar
  product: Jekyll Doc Theme
  version: 6.0
  folders:

Simply replacing 6.0 with {% project_version %} generates the error

found character that cannot start any token while scanning for the next token

I tried naively to "escape" this sequence with more brackets and quotes, but I couldn't find a way that would work. It would be extremely useful for me if there was a way to fix this!

@MarkWieczorek
Copy link
Contributor

I found a workaround to this, but it involves editing one of the template files:

  1. Add gem 'jekyll_version_plugin', group: :jekyll_plugins to the Gemfile, and then execute bundle update .
  2. Find the file _includes\sidebar.html, and then
  3. replace the single occurence of {{sidebar[0].version}} with {% project_version %}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants