Cannot use frontmatter variables (or any variables at all) in raw HTML #4205
-
PrefaceCurrently the site is on GitHub Pages, and GitHub does not let us add real 302s, so we added a canonical refresh in order to not break old links from other places. Since we have... well, quite a few of these "dead paths" it made sense to use an Markdown fragment for it. The objective is to be able to use a Markdown include for the meta refreshes, with a frontmatter variable so that the include fragment actually knows where to go. Previously on Jekyll we did this using an include parameter, but this seems to be a Liquid-specific function and not available in markdown-it-include. Unfortunately this doesn't seem to work. The following snippet is an example with it inline, but the same applies to fragments regardless: ---
title: Redirecting...
redirect_to: "https://github.com"
---
Redirecting to {{ $frontmatter.redirect_to }}
<meta http-equiv="refresh" content="0; URL={{ $frontmatter.redirect_to }}">
<link rel="canonical" href="{{ $frontmatter.redirect_to }}"> It produces: <p>Redirecting to https://github.com</p>
<meta http-equiv="refresh" content="0; URL={{ $frontmatter.redirect_to }}">
<link rel="canonical" href="{{$frontmatter.redirect_to}}"> Is this a known limitation? I'd have thought the pre-processor applies it to the entire file instead of what seems to be "only what it wants to pre-process". NoteThis is similar to the issue here: #3787. I tried doing it this way, but the variables that matter didn't actually get processed still. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It's vue. https://vuejs.org/guide/essentials/template-syntax.html#attribute-bindings <meta http-equiv="refresh" :content="`0; URL=$frontmatter.redirect_to`"> but even then meta tags should be part of ---
head:
- - meta
- http-equiv: refresh
content: '0; URL= https://github.com'
--- |
Beta Was this translation helpful? Give feedback.
It's vue. https://vuejs.org/guide/essentials/template-syntax.html#attribute-bindings
but even then meta tags should be part of
<head>
to work. You can do something like:https://vitepress.dev/reference/frontmatter-config#head