title: Change Meta Title and Description using Vue.js
body: <p>Is it possible to change anything higher than the body tag in Vue.Js? The contents for both these elements is currently stored in the JSON file that is attached to an element further down the DOM tree.</p>
  
  <p>I need to try and inject a meta title and description that can be crawled by Google (ie. It injects, then renders before it gets crawled) and understand the issues with accessing the body element and higher up the DOM tree, as the current Vue JSON is injected using the App ID on a DIV lower down.</p>
  
  <p>I have previously used some jQuery code to address this issue on a Square Space template in some previous work</p>
  
  <p><code>jQuery('meta[name=description]').attr('content', 'Enter Meta Description Here');</code></p>
  
  <p>PAGE HTML</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"&gt;
    &lt;meta name="description" content="{{items[0][0].meta-desc}}"&gt;
    &lt;meta name="author" content=""&gt;
    &lt;title&gt;{{items[0][0].meta-title}}&lt;/title&gt;
    &lt;!-- Bootstrap CSS --&gt;
    &lt;link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"&gt;
    &lt;!-- Vue.js CDN --&gt;
    &lt;script src="https://unpkg.com/vue"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;!-- Page List --&gt;
    &lt;div class="container text-center mt-5" id="app"&gt;
        &lt;h1 class="display-4"&gt;Vue Page Output:&lt;/h1&gt;
        &lt;h2&gt;{{items[0][0].page1}}&lt;/h2&gt;
    &lt;/div&gt;
    &lt;div class="container text-center mt-5"&gt;
      &lt;h3&gt;Other Pages&lt;/h3&gt;
      &lt;a href="products.html"&gt;Products&lt;/a&gt;
      &lt;a href="contactus.html"&gt;Contact Us&lt;/a&gt;
  &lt;/div&gt;
    &lt;!-- /.container --&gt;
  
    &lt;script type="text/javascript"&gt;
      const app = new Vue({
        el: '#app',
        data: {
          items: []
        },
        created: function () {
          fetch('test.json')
            .then(resp =&gt; resp.json())
            .then(items =&gt; {
              this.items = items
            })
        }
      });
    &lt;/script&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>JSON</p>
  
  <pre><code>  [
      [
      {
          "page1": "Company Name",
          "meta-title": "Acme Corp"
          "meta-desc": "Welcome to Acme Corp"
      }
      ],
      [
      {
          "products": "Product List"
      }
      ],
      [
      {
          "contactus": "Contact Us at Acme Corp"
      }
    ]
  </code></pre>
  
  <p>Here is the code in action, the incoming JSON file comes in a fixed array format with the meta details alongside the body elements. Making this a bit more tricky.</p>
  
  <p><a href="https://arraydemo.netlify.com/" rel="noreferrer">https://arraydemo.netlify.com/</a></p>