You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Can't use anything for a button-link URL other than a string? #222
We're using Sphinx/MyST-Parser/MyST Markdown/Sphinx-Design. Sphinx-Design is really nice and has made creating an adaptable web layout very easy, so thanks.
We have one problem though. Various external URLs used on our site need to automatically adapt to the current release version being changed in conf.py.
Across the site this is in general done using myst_substitutions to insert the appropriate URL, and the URLs are defined using f-strings in conf.py so that the up-to-date URLs are generated at build time. This works fine in most places, up until wanting to use it in some Sphinx-Design buttons that I am trying to make.
Previously a particular set of link buttons were created within a Sphinx-Design card like so:
The resulting link works fine but the created button has awkward formatting and looks out of place next to the native Sphinx-Design ones, so I tried to turn them into proper SD buttons:
I've scoured the web and tried myst_url_schemes as well as what feels like every possible syntax and nothing works. Why don't any of the syntaxes with ', {, <, ", ``, do anything other than pass the literal characters in this situation? Is there any way to give a URL argument to the {button-link} directive as anything other than a simple string?
Thanks for the clear write-up. MyST substitutions are applied to text, not to directive arguments, so {{winurl}} reaches button-link literally; this is MyST-Parser behaviour rather than something sphinx-design controls. A workaround that works today is to put the whole button in a substitution built in conf.py, e.g. myst_substitutions = {"winbutton": f":::{{button-link}} {winurl}\n:color: primary\n:outline:\nDownload Installer\n:::"} and then write {{ winbutton }} on a line of its own. That renders a normal sphinx-design button with the up-to-date URL. Closing as answered; if you would like substitutions inside directive arguments in general, that would be a feature request for MyST-Parser.
Activity
chrisjsewell commentedon Nov 10, 2026
Thanks for the clear write-up. MyST substitutions are applied to text, not to directive arguments, so
{{winurl}}reachesbutton-linkliterally; this is MyST-Parser behaviour rather than something sphinx-design controls. A workaround that works today is to put the whole button in a substitution built inconf.py, e.g.myst_substitutions = {"winbutton": f":::{{button-link}} {winurl}\n:color: primary\n:outline:\nDownload Installer\n:::"}and then write{{ winbutton }}on a line of its own. That renders a normal sphinx-design button with the up-to-date URL. Closing as answered; if you would like substitutions inside directive arguments in general, that would be a feature request for MyST-Parser.