# Need a little help with embedding/static page

**URL:** <https://talk.observablehq.com/t/need-a-little-help-with-embedding-static-page/1904>\
**Category:** Uncategorized\
**Created:** [April 22, 2019, 3:38pm UTC](https://talk.observablehq.com/t/need-a-little-help-with-embedding-static-page/1904 "2019-04-22T15:38:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![greencracker](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/greencracker/32/1686_2.png) [@greencracker](https://talk.observablehq.com/u/greencracker)\
**Post date:** [April 22, 2019, 3:38pm UTC](https://talk.observablehq.com/t/need-a-little-help-with-embedding-static-page/1904/1 "2019-04-22T15:38:50Z")

</div>

UPDATED: Hi All, I’ve tried the embedding tutorials, which have gotten me 95% of the way there.  
(I’m not linking them here b/c I cant include too many links in this)

But I just can’t get mine to work. I’m trying to embed just the chart only. I feel like it’s properly in a cell named “chart.” That’s the name on the left side of the cell. But yes, somehow it’s apparently not finding any child named “chart.”

Here’s my notebook:

> **[Treemap](https://observablehq.com/@greencracker/treemap)**
>
> An Observable notebook by Maggie Lee.

Here’s my working webpage:  
The console is giving me an error "Cannot read property ‘appendChild’ of null:

[http://greencracker.pythonanywhere.com/budget-2020/chart-only.html](http://greencracker.pythonanywhere.com/budget-2020/chart-only.html)

---

<div class="post-metadata">

**Author:** ![aaronkyle](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/aaronkyle/32/8106_2.png) [@aaronkyle](https://talk.observablehq.com/u/aaronkyle)\
**Post date:** [April 22, 2019, 3:47pm UTC](https://talk.observablehq.com/t/need-a-little-help-with-embedding-static-page/1904/2 "2019-04-22T15:47:33Z")

</div>

Hi Maggie.

Try removing the following line:

```
Runtime.load(notebook, Inspector.into(document.body));

```

Looks like it works:

[https://aaronkyle.github.io/concept/data-visualization/sandbox/greencracker.html](https://aaronkyle.github.io/concept/data-visualization/sandbox/greencracker.html)

---

<div class="post-metadata">

**Author:** ![greencracker](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/greencracker/32/1686_2.png) [@greencracker](https://talk.observablehq.com/u/greencracker)\
**Post date:** [April 22, 2019, 3:49pm UTC](https://talk.observablehq.com/t/need-a-little-help-with-embedding-static-page/1904/3 "2019-04-22T15:49:33Z")

</div>

Thanks! But how can I get just the chart, not the code?

I just amended my question a good bit. There is an error in the console when I add this:

```
Runtime.load(notebook, (cell) => {
          if (cell.name === "chart") {
            return {
              fulfilled: (value) => {
                document.getElementById("chart").appendChild(value);
              }
            };
          }
        });
```

---

<div class="post-metadata">

**Author:** ![aaronkyle](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/aaronkyle/32/8106_2.png) [@aaronkyle](https://talk.observablehq.com/u/aaronkyle)\
**Post date:** [April 22, 2019, 3:55pm UTC](https://talk.observablehq.com/t/need-a-little-help-with-embedding-static-page/1904/4 "2019-04-22T15:55:53Z")

</div>

> [@greencracker](#):
>
> Thanks! But how can I get just the chart, not the code?

Try this version:

```
<html>
    <body>
    
    <div class="wrapper">
      <div class="title">TEST</div>
      <div id="output"></div>
    </div>
   
    </body>
    
    <script type="module">
       // Load the Observable runtime and inspector
      import {Inspector, Runtime} from "https://unpkg.com/@observablehq/notebook-runtime@2?module";
          // Load your notebook, compiled as an ES module.
      import notebook from "https://api.observablehq.com/@greencracker/treemap.js";
      const renders = {
        "chart": "#output",
      };
  
  for (let i in renders)
    renders[i] = document.querySelector(renders[i]);

  Runtime.load(notebook, (variable) => {
    if (renders[variable.name])
      return new Inspector(renders[variable.name]);
  });
    </script>
    
   

</html>

```

[https://aaronkyle.github.io/concept/data-visualization/sandbox/greencracker-cell](https://aaronkyle.github.io/concept/data-visualization/sandbox/greencracker-cell)

Where the code says

```
  const renders = {
    "chart": "#output",
  };

```

You can add in more cells to call in explicitly.

For example

```
  const renders = {
    "chart": "#output",
    "viewof tile": "#input",
  };

```

Just make sure there’s a corresponding `<div>` element in your HTML document.

---

<div class="post-metadata">

**Author:** ![greencracker](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/greencracker/32/1686_2.png) [@greencracker](https://talk.observablehq.com/u/greencracker)\
**Post date:** [April 22, 2019, 3:59pm UTC](https://talk.observablehq.com/t/need-a-little-help-with-embedding-static-page/1904/5 "2019-04-22T15:59:33Z")

</div>

Perfect, thank you!!

I managed to stumble upon doing this too, in case anyone else is reading this, I think it makes a little more sense to beginners – it’s the same principle but less modular – adding a div by hand at the top 🙂

```
<html>
    <body></body>
    <div id="chart"></div>
    <script type="module">
      // Load the Observable runtime and inspector.
        import {Runtime, Inspector} from "https://unpkg.com/@observablehq/notebook-runtime?module";

      // Your notebook, compiled as an ES module.
        import notebook from "https://api.observablehq.com/@greencracker/treemap.js";

        Runtime.load(notebook, (cell) => {
          return {
            pending: () => console.log(`${cell.name} is running...`),
            fulfilled: (value) => console.log(cell.name, value),
            rejected: (error) => console.error(error)
          };
        });

        Runtime.load(notebook, (cell) => {
          if (cell.name === "chart") {
            return {fulfilled: (value) => $("chart").append(value)};
          } else {
            // Force evaluation of all the other cells in the notebook.
            return true;
          }
        });

        Runtime.load(notebook, (cell) => {
          if (cell.name === "chart") {
            return {
              fulfilled: (value) => {
                document.getElementById("chart").appendChild(value);
              }
            };
          }
        });

    </script>

</html>
```
