Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
Referencing GraphQL variable used in query in Gatsby template?

I am aggregating all posts that have a certain tag in it's tag list:


export const Search = graphql`
  query SearchResults($tag: String = "") {
    allMarkdownRemark(filter: { frontmatter: { tags: { in: [$tag] } } }) {
      nodes {
        frontmatter {
          title
          date
        }
      }
    }
  }
`

The query works great, but I want to also be able to dynamically show the tag that is being queried for. How can I pass this information through?

For example: Searching results for tag: Java which would be the value inside $tag in the graphql query.

I tried to pull from the URL, but it's rendered in node, so I don't have access to the window object and it felt a bit hacky anyway.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I got it. Passing in props.pageContext gives you access to the contextual information passed in via gatsby-node.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!