# Advanced Embedding - howto render all cells except certain cells

**URL:** <https://talk.observablehq.com/t/advanced-embedding-howto-render-all-cells-except-certain-cells/7612>\
**Category:** Help\
**Created:** [February 8, 2023, 6:01am UTC](https://talk.observablehq.com/t/advanced-embedding-howto-render-all-cells-except-certain-cells/7612 "2023-02-08T06:01:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bcrock](https://avatars.discourse-cdn.com/v4/letter/b/c6cbf5/32.png) [@bcrock](https://talk.observablehq.com/u/bcrock)\
**Post date:** [February 8, 2023, 6:01am UTC](https://talk.observablehq.com/t/advanced-embedding-howto-render-all-cells-except-certain-cells/7612/1 "2023-02-08T06:01:53Z")

</div>

I’m following this example: [Advanced embeds | Observable documentation](https://observablehq.com/@observablehq/advanced-embeds)

and I see how I can select one cell to embed. How might I render all cells except one or two cells?

> If you don’t want to render the entire notebook, define a custom function to control which cells are rendered and where they go. For example, to render just the cell named “chart” into the DOM element with the same id, say:
> 
> ```auto
> new Runtime().module(notebook, name => {
> if (name === "chart") {
> return new Inspector(document.querySelector("#chart"));
> }
> });
> 
> ```

In my case I’m trying to embed all cells except the one called “notebook\_title” from this notebook.

> **[Into The Great PD](https://observablehq.com/@bcrock/into_the_great_public_domain)**
>
> A Sustainability project in it's early phases which is gaining momentum in 2023 Vision 100% of the designs for sustainable production of food housing, healthcare and education for every human and animal are available in the Public Domain Mission...

As an extension, what if I wanted to exclude another cell called “hide\_me”?

---

<div class="post-metadata">

**Author:** ![mootari](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mootari/32/581_2.png) [@mootari](https://talk.observablehq.com/u/mootari)\
**Post date:** [February 8, 2023, 10:17am UTC](https://talk.observablehq.com/t/advanced-embedding-howto-render-all-cells-except-certain-cells/7612/2 "2023-02-08T10:17:45Z")

</div>

WIth iframe embeds you currently only have the choice to embed the entire notebook or a subset of named cells.

If your question is about custom embeds, then you can invert your filtering, returning a falsish value instead of an observer for this particular cell:

```javascript
{
  const {Runtime, Inspector} = await import("https://esm.sh/@observablehq/runtime");
  const {default: define} = await import("https://api.observablehq.com/@bcrock/into_the_great_public_domain.js?v=4");
  
  const container = document.createElement("div");
  const inspect = Inspector.into(container);
  
  new Runtime().module(define, name => {
    if(name !== "notebook_title") return inspect(name);
  });
  
  return container;
}

```

I’ve given this example as a notebook cell, but hopefully you’ll be able to adapt it. (If not, let me know!)

---

<div class="post-metadata">

**Author:** ![bcrock](https://avatars.discourse-cdn.com/v4/letter/b/c6cbf5/32.png) [@bcrock](https://talk.observablehq.com/u/bcrock)\
**Post date:** [February 10, 2023, 1:27am UTC](https://talk.observablehq.com/t/advanced-embedding-howto-render-all-cells-except-certain-cells/7612/3 "2023-02-10T01:27:15Z")

</div>

Thanks mootari! yes that was the answer I was looking for, but I am having trouble adapting it to an HTML page. I have one example working, but when I modify it to match your pattern, I can’t get the page to load. I’ve tried a bunch of variations but so far no luck. Any suggestions? Thank you!

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/observablehq/original/2X/9/9ca463c7f6ab9e487c90dd76fd175264cf185cb8.png)

---

<div class="post-metadata">

**Author:** ![mootari](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mootari/32/581_2.png) [@mootari](https://talk.observablehq.com/u/mootari)\
**Post date:** [February 10, 2023, 2:01am UTC](https://talk.observablehq.com/t/advanced-embedding-howto-render-all-cells-except-certain-cells/7612/4 "2023-02-10T02:01:28Z")

</div>

In your first example, note how you’re not doing anything with `container`: it just sits there and will be garbage collected, unless you append it to the document’s body. Also, any dynamic imports can be replaced with static imports, since your script type is “module”.

Long story short, change your second example to:

```javascript
const inspect = Inspector.into("#observablehq-974acc8");
new Runtime().module(define, name => {
  if(name !== "notebook_title") return inspect(name);
});

```

---

<div class="post-metadata">

**Author:** ![bcrock](https://avatars.discourse-cdn.com/v4/letter/b/c6cbf5/32.png) [@bcrock](https://talk.observablehq.com/u/bcrock)\
**Post date:** [February 10, 2023, 4:02am UTC](https://talk.observablehq.com/t/advanced-embedding-howto-render-all-cells-except-certain-cells/7612/5 "2023-02-10T04:02:00Z")

</div>

Thanks again. You had a typo in the 97a4acc8 but I found it and it works as expected. It’s also helpful to know that containers need to be attached to a body, and to know that the two patterns of imports are dynamic vs static. I guess that means that cell and module scripts have different requirements for scripting, I’ll keep an eye out for that.

---

<div class="post-metadata">

**Author:** ![mootari](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mootari/32/581_2.png) [@mootari](https://talk.observablehq.com/u/mootari)\
**Post date:** [February 10, 2023, 11:17am UTC](https://talk.observablehq.com/t/advanced-embedding-howto-render-all-cells-except-certain-cells/7612/6 "2023-02-10T11:17:12Z")

</div>

> [@bcrock](#):
>
> You had a typo in the 97a4acc8

Next time please share the actual code instead of a screenshot.

> [@bcrock](#):
>
> I guess that means that cell and module scripts have different requirements for scripting, I’ll keep an eye out for that.

The main difference here is that cells aren’t modules, and therefore can’t use static imports (which need to go at the top of a script).

For other differences have a look at

> **[JavaScript cell | Observable documentation](https://observablehq.com/documentation/cells/javascript)**
>
> All your Observable questions answered

---

<div class="post-metadata">

**Author:** ![bcrock](https://avatars.discourse-cdn.com/v4/letter/b/c6cbf5/32.png) [@bcrock](https://talk.observablehq.com/u/bcrock)\
**Post date:** [February 11, 2023, 11:38pm UTC](https://talk.observablehq.com/t/advanced-embedding-howto-render-all-cells-except-certain-cells/7612/7 "2023-02-11T23:38:37Z")

</div>

Sorry about the screenshot - I was trying to paste code but was having trouble pasting the code in my message… it seems like the page was trying to render my HTML. I just researched to find the preformatted text button, and if this renders properly, I get it now.

```auto
<HTML><HEAD></HEAD><BODY>
Test HTML
</BODY></HTML>

```
