Skip to content

Custom shortcodes to avoid hardcoding journal citation #131

Discussion options

You must be logged in to vote

Hi Sophie, when you said:

I cannot use partials with markdown pages, but am yet to figure out how I might do this with a shortcode.

You're absolutely correct that partials can't be used directly in Markdown pages, but the nice thing is that you can usually create a very simple shortcode that acts as a wrapper for an existing partial.

If you had a shortcode called q-cite-this.thml with this code inside it:

{{- $type := .Get "type" -}}
{{- $range := .Get "range" -}}

<p>{{ partial "cite-this.html" ( dict "page" . "site" .Site "type" $type "range" $range ) }}</p>

You could then call it in the markdown, as:

## Citation Information

### Chicago

{{< q-cite-this type="chicago" range="site" >…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Erin-Cecele
Comment options

@sophielamb
Comment options

@Erin-Cecele
Comment options

Answer selected by Erin-Cecele
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants