title: I am having trouble with a shopify liquid for loop in Jekyll
body: <p>The below code is slightly different than what is <a href="https://redhawk989.github.io/EyeTrackVR/faq/" rel="nofollow noreferrer">rendered</a>, I haven't pushed my changes yet. So keep that in mind.</p>
  <p>It is supposed to</p>
  <ul>
  <li>iterate through the YAML data file.</li>
  <li>place a link everywhere that is required of it.</li>
  </ul>
  <p>However, currently, it is only placing the last element seen by the for loop everywhere I want a link.</p>
  <p>I have a YAML file with two links, and instead of placing the link in the block associated with its PID, it is placing the second link in all link locations.</p>
  <p>I am using REGEX to parse, so anywhere in the YAML file that is <code>aaaa</code> a link gets replaced at that location. That works, it just doesn't place the right link.</p>
  <p>Now the even more confusing part is that the first console.log <code>console.log(faqLink{{ faq_link_pid }});</code> prints all of the links, correctly and in the order, they are in the file.</p>
  <pre class="lang-html prettyprint-override"><code>&lt;h1 class=&quot;fs-6 fw-500&quot; align=&quot;center&quot;&gt;Frequently Asked Questions &lt;br&gt; Welcome to our FAQ!&lt;/h1&gt;
  &lt;div class=&quot;accordiobody&quot;&gt;
      {% for faq in site.data.faq_yaml.frequently_asked_questions %}
      &lt;div class=&quot;accordion&quot;&gt;
          &lt;hr&gt;
          &lt;div class=&quot;container&quot;&gt;
              &lt;div class=&quot;question fw-400&quot;&gt;
                  &lt;h1 class=&quot;fs-5 fw-500&quot;&gt;
                      {{ faq.question }}
                  &lt;/h1&gt;
              &lt;/div&gt;
              &lt;div class=&quot;answer&quot;&gt;
                  &lt;blockquote&gt;
                      &lt;span class=&quot;answerspan&quot;&gt;
                          {{ faq.answer }}
                      &lt;/span&gt;
                  &lt;/blockquote&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      {% endfor %}
  &lt;/div&gt;
  &lt;script type=&quot;text/javascript&quot;&gt;
      {% assign faq_link = &quot;&quot; %}
      {% assign faq_link_description = &quot;&quot; %}
      {% assign faq_link_pid = 0 %}
      {% for faq in site.data.faq_yaml.frequently_asked_questions %}
      {% if faq.hyper_link != null and faq.hyper_link != &quot;&quot; %}
      {% assign faq_link = faq.hyper_link %}
      {% assign faq_link_pid = faq.faq_link_pid %}
      
  
      const faqLink{{ faq_link_pid }} = &quot;{{ faq_link }}&quot;;
      {% if faq.link_description != null and faq.link_description != &quot;&quot; %}
      {% assign faq_link_description = faq.link_description %}
      const faqLinkDescription{{ faq_link_pid }} = &quot;{{ faq_link_description }}&quot;;
      console.log(faqLink{{ faq_link_pid }});
      function createElement() {
              for (let x in accordion) {
                  const link{{ faq_link_pid }} = `&lt;a href=&quot;${faqLink{{ faq_link_pid }}} &quot; target=&quot;_blank&quot;&gt;${faqLinkDescription{{ faq_link_pid }}}&lt;/a&gt;`;
                  console.log(link{{ faq_link_pid }});
                  replaceLink(link{{ faq_link_pid }});
          }
      }
      {% endif %}
      window.addEventListener('load', function () {
          createElement();
      });
      {% endif %}
      {% endfor %}
  
      const accordion = document.getElementsByClassName('container');
  
      for (i = 0; i &lt; accordion.length; i++) {
          accordion[i].addEventListener('click', function () {
              this.classList.toggle('active');
          })
      }
  
      function replaceLink(str) {
          const link = document.querySelectorAll('.answerspan');
          const all_link = link.forEach(function (link) {
              const hyper_link = link.innerHTML;
              link.innerHTML = hyper_link.replace(/aaaa./g, str);
          });
      }
  &lt;/script&gt;
  </code></pre>
  <p>The YAML file:</p>
  <pre class="lang-yaml prettyprint-override"><code>---
  # Use this YAML file to create a list of FAQ questions and answers.
  
  - question: &quot;How will this work?&quot;
    answer: &quot;Currently, a camera is mounted inside the headset for each eye. The camera streams through wifi to a PC client which processes and sends eye-tracking data to VR Chat.&quot;
    hyper_link: &quot;&quot;
    link_description: &quot;&quot;
    faq_link_pid: 3
  
  - question: &quot;What features will be supported?&quot;
    answer: &quot;The goal is eye tracking with eye openness and some form of pupil dilation. A far away aspiration of this project is some form of weak foveated rendering because it's cool and any small performance increase in VR is welcome.&quot;
    hyper_link: &quot;&quot;
    link_description: &quot;&quot;
    faq_link_pid: 4
  
  - question: &quot;When will this be completed?&quot;
    answer: &quot;When it's done  I have a semi-busy life so development may slow and speed up inconsistently. I have a goal to be done with all base features in June.&quot;
    hyper_link: &quot;&quot;
    link_description: &quot;&quot;
    faq_link_pid: 5
  
  - question: &quot;Will IR damage my eyes?&quot;
    answer: &quot;This project has safety in mind. If you do all of the safety measures we put in place and visually test the amount of IR light you will be fine. Please note we have not finished development of all safety stuff so be careful aaaaa  .&quot;
    hyper_link: &quot;https://dammedia.osram.info/media/bin/osram-dam-2496608/AN002_Details%20on%20photobiological%20safety%20of%20LED%20light%20sources.pdf&quot;
    link_description: &quot;here is a pdf with safety information&quot;
    faq_link_pid: 6
  
  - question: &quot;How expensive will this be?&quot;
    answer: &quot;My goal is to keep it as cheap as possible with around $75 as the absolute max, with current projections being around $25-40&quot;
    hyper_link: &quot;&quot;
    link_description: &quot;&quot;
    faq_link_pid: 7
  
  - question: &quot;How do I set up my avatar?&quot;
    answer: &quot;Check out the VR Chat face tracking wiki on our GitHub. Keep in mind that we currently only support float parameters. aaaa &quot;
    hyper_link: &quot;https://google.com&quot;
    link_description: &quot;Google&quot;
    faq_link_pid: 8
  ---
  
  </code></pre>