# Handy Embed Code for shared notebooks

**URL:** <https://talk.observablehq.com/t/handy-embed-code-for-shared-notebooks/3834>\
**Category:** Feedback\
**Created:** [September 3, 2020, 10:16pm UTC](https://talk.observablehq.com/t/handy-embed-code-for-shared-notebooks/3834 "2020-09-03T22:16:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcmcclur](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mcmcclur/32/2364_2.png) [@mcmcclur](https://talk.observablehq.com/u/mcmcclur)\
**Post date:** [September 3, 2020, 10:16pm UTC](https://talk.observablehq.com/t/handy-embed-code-for-shared-notebooks/3834/1 "2020-09-03T22:16:57Z")

</div>

The [Handy Embed Code Generator](https://observablehq.com/@jashkenas/handy-embed-code-generator) no longer seems to work for _shared_ notebooks. For example, here’s a notebook that I shared recently:

> **[Stat problems on normal computations](https://observablehq.com/d/2f037ab01d3a1ed2)**

If I go to the [Handy Embed Code Generator](https://observablehq.com/@jashkenas/handy-embed-code-generator) and type in the identifier `2f037ab01d3a1ed2` or include the ‘d’ to get `d/2f037ab01d3a1ed2` I get an error. It’s clearly trying and I’m quite sure I’ve done this before but, no more.

* * *

To be clear, it just the code generator itself that is broken and only when applied to shared notebooks. It works fine for published notebooks. In addition, the embedding procedure itself works fine. Thus, if you know how to do it, it’s still easy to embed a shared notebook - it’s just not … handy. 🙂

For example, the above link is [embedded here](https://marksmath.org/classes/Fall2020Stat185/problem_sheets/09.02.20.InClass.html).

---

<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:** [September 3, 2020, 10:28pm UTC](https://talk.observablehq.com/t/handy-embed-code-for-shared-notebooks/3834/2 "2020-09-03T22:28:33Z")

</div>

The notebook fetches the v3 format and parses the frontmatter at the beginning of a notebook source.

Interestingly, the frontmatter is now missing in unpublished notebooks. v1 still has it.

Shameless plug: I have support for both formats in `getPinnedSlug()`:

> **[Toolbox](https://observablehq.com/d/691ae3b95f02db79#getPinnedSlug)**
>
> An Observable notebook by Fabian Iwand.

---

<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:** [September 3, 2020, 10:54pm UTC](https://talk.observablehq.com/t/handy-embed-code-for-shared-notebooks/3834/3 "2020-09-03T22:54:16Z")

</div>

Here’s a fix that fetches the metadata from v1 instead ([compare](https://observablehq.com/compare/7105991ec342b0dc@425...f22905a949f6c00c@440)):

> **[Handy Embed Code Generator](https://observablehq.com/d/f22905a949f6c00c)**
>
> An Observable notebook by Fabian Iwand.

---

<div class="post-metadata">

**Author:** ![mcmcclur](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mcmcclur/32/2364_2.png) [@mcmcclur](https://talk.observablehq.com/u/mcmcclur)\
**Post date:** [September 3, 2020, 11:27pm UTC](https://talk.observablehq.com/t/handy-embed-code-for-shared-notebooks/3834/5 "2020-09-03T23:27:49Z")

</div>

> [@mootari](#):
>
> Here’s a fix that fetches the metadata from v1 instead ([compare](https://observablehq.com/compare/7105991ec342b0dc@425...f22905a949f6c00c@440)):

Most excellent - thanks! Might be worth sending it as a suggestion to @jashkenas.

---

<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:** [September 3, 2020, 11:40pm UTC](https://talk.observablehq.com/t/handy-embed-code-for-shared-notebooks/3834/6 "2020-09-03T23:40:21Z")

</div>

> [@mcmcclur](#):
>
> Might be worth sending it as a suggestion

Already done, the compare link is taken from the suggestion. 🙂

---

<div class="post-metadata">

**Author:** ![tophtucker](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/tophtucker/32/4781_2.png) [@tophtucker](https://talk.observablehq.com/u/tophtucker)\
**Post date:** [September 4, 2020, 10:45pm UTC](https://talk.observablehq.com/t/handy-embed-code-for-shared-notebooks/3834/7 "2020-09-04T22:45:42Z")

</div>

The comment that Jeremy’s Handy notebook depended on to find the version was recently removed from nonpublic notebooks to reduce the risk of downloaded source accidentally leaking the location of a nonpublic notebook. (Like, if you download it and use it somewhere, as opposed to a direct embed.) We’re workin on easier ways to embed, so this shouldn’t be a problem for long! Good eye.

---

<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:** [September 4, 2020, 11:25pm UTC](https://talk.observablehq.com/t/handy-embed-code-for-shared-notebooks/3834/8 "2020-09-04T23:25:49Z")

</div>

> [@tophtucker](#):
>
> to reduce the risk of downloaded source accidentally leaking

Perhaps you can add back a comment that contains only the version (similar to the frontmatter in v1)?  
Or alternatively support a `@latest` version identifier that will redirect to a specific version? Then the version could be parsed from `response.url`.
