-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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
feat: Allow to reference (Jekyll) variables in YAML files #8783
Comments
This issue has been automatically marked as stale because it has not been commented on for at least two months. The resources of the Jekyll team are limited, and so we are asking for your help. If this is a bug and you can still reproduce this error on the latest If this is a feature request, please consider building it first as a plugin. Jekyll 3 introduced hooks which provide convenient access points throughout the Jekyll build pipeline whereby most needs can be fulfilled. If this is something that cannot be built as a plugin, then please provide more information about why in order to keep this issue open. This issue will automatically be closed in two months if no further activity occurs. Thank you for all your contributions. |
I'm just starting with Jekyll so I can't tell if this could be done with hooks. And I believe ai explained the 'why' quite well. Of course, if a human has a specific question, I'd be more than happy to try and give an answer. |
This issue has been automatically marked as stale because it has not been commented on for at least two months. The resources of the Jekyll team are limited, and so we are asking for your help. If this is a bug and you can still reproduce this error on the latest If this is a feature request, please consider building it first as a plugin. Jekyll 3 introduced hooks which provide convenient access points throughout the Jekyll build pipeline whereby most needs can be fulfilled. If this is something that cannot be built as a plugin, then please provide more information about why in order to keep this issue open. This issue will automatically be closed in two months if no further activity occurs. Thank you for all your contributions. |
Summary
Make it possible to reference (Jekyll) variables (from the same or other files) in a given variable in YAML (configuration) files.
Motivation
My use-case is that I would like to easily and quickly record my username and server of a federated service in my site's
_config
file, which the theme then can use to create different variables (e.g. my username and my profile URL) based on these, in the background.My variables in
_config.yml
:The variables created by the theme, and usable in page elements:
But I think that the ability to reference variables will enable many more options in completely different contexts.
As this is a 'basic' (not 'simple', but as in 'high-level') functionality and not enabling a specific feature (e.g. an RSS feed), I believe this should be in core (not a plugin).
Guide-level explanation
You can reference Jekyll variables in any YAML configuration file. By including a reference, its value will be 'printed' as a string or integer (depending on the source and target variables) in the new variable.
It is possible to have 'nested' references, as follows:
If variable
C
references variableB
, and variableB
references variableA
, the value of variableA
will show in the value of variableC
(even though variableC
doesn't directly reference variableA
).Note, however, that this should not lead to vicious circles, where variables reference each-other, as here:
If such circular references occur this will lead to an error, and your site will fail to build.
Reference-level explanation
Sorry, just got started with Jekyll, so I don't know what to write here.
Drawbacks
There's extra functionality to maintain and create tests for. And this might be complex if people start making deeply nested variables with vicious circles. Creating helpful error messages that clearly indicate where a circular reference appears might be complicated (?)
Unresolved Questions
The text was updated successfully, but these errors were encountered: