# How to display plotly graph on github pages?

**URL:** <https://community.plotly.com/t/how-to-display-plotly-graph-on-github-pages/44398>\
**Category:** 📊 Plotly Python\
**Created:** [September 1, 2020, 3:51am UTC](https://community.plotly.com/t/how-to-display-plotly-graph-on-github-pages/44398 "2020-09-01T03:51:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![charlie66](https://avatars.discourse-cdn.com/v4/letter/c/dbc845/32.png) [@charlie66](https://community.plotly.com/u/charlie66)\
**Post date:** [September 1, 2020, 3:51am UTC](https://community.plotly.com/t/how-to-display-plotly-graph-on-github-pages/44398/1 "2020-09-01T03:51:16Z")

</div>

I am trying to display a plotly graph on github page (not the static image)

On Stackoverflow I found this:

> <https://stackoverflow.com/questions/60513164/display-interactive-plotly-chart-html-file-on-github-pages>

I generated the HTML file and set up \_includes folder, but it didnt work for me, I couldn’t find any similar question on Google, please help

---

<div class="post-metadata">

**Author:** ![pokgak](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/pokgak/32/16341_2.png) [@pokgak](https://community.plotly.com/u/pokgak)\
**Post date:** [September 19, 2020, 8:28am UTC](https://community.plotly.com/t/how-to-display-plotly-graph-on-github-pages/44398/2 "2020-09-19T08:28:04Z")

</div>

I did this in my [repository](https://github.com/pokgak/ba-plotscripts). You need to enable Github Pages for the repo in the Settings but you don’t need to use Jekyll. You can commit the output files of `write_html()` and push it to the repository. After that you can access the graph by using URL in format `<username>.github.io/<repository>/<filepath>`.

This is an example of how I configure my repo:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/8/86e69b285d776ad19f7507b203d4592546435164.png)

---

<div class="post-metadata">

**Author:** ![alaa137](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@alaa137](https://community.plotly.com/u/alaa137)\
**Post date:** [May 23, 2021, 9:30am UTC](https://community.plotly.com/t/how-to-display-plotly-graph-on-github-pages/44398/3 "2021-05-23T09:30:32Z")

</div>

Can you please elaborate on this a little bit? After enabling Github Pages and committing the html file, what should I write in the .md file to display it? Of course simply typing the link `my-username.github.io/my-repo/path/to/file.html` doesn’t display the content…

Thanks in advance 🙂

---

<div class="post-metadata">

**Author:** ![pokgak](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/pokgak/32/16341_2.png) [@pokgak](https://community.plotly.com/u/pokgak)\
**Post date:** [September 12, 2021, 1:06pm UTC](https://community.plotly.com/t/how-to-display-plotly-graph-on-github-pages/44398/4 "2021-09-12T13:06:44Z")

</div>

Sorry to necro this thread but since the link to my old repo is now gone since I archived the repo. Here’s an updated guide for those who stumbled across this.

I have a [script (main.py)](https://github.com/pokgak/citf-graphs/blob/main/main.py) that I used to generate a plain HTML containing a Plotly graph that can be viewed from my Github Pages site ([https://pokgak.xyz/citf-graphs/](https://pokgak.xyz/citf-graphs/)).

1. Enable Github Pages. Here’s an example of my setting for the example:  

2. Create your plot as usual and at the end import it to HTML using the `write_html` function. Snippet from my script: [citf-graphs/main.py at 1080a51151ba0029ba611ba9d3cb59e77809513a · pokgak/citf-graphs · GitHub](https://github.com/pokgak/citf-graphs/blob/1080a51151ba0029ba611ba9d3cb59e77809513a/main.py#L26-L37)

Since the file is just plain HTML, Github Pages will pick it up. Bonus if you name your file `index.html` and put it at the configured root directory of your Github Pages setting like I did in my example repo. Then, Github will automatically shows it when you go to the Github Pages URL of that repository. In my case, this is [pokgak.github.io/citf-graphs](http://pokgak.github.io/citf-graphs).

Example file structure of my repo:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/7/4/74596aa5ad989a4a779df79fc5738e6cefcb6f53.png)

If you name your file other than that, then you’ll need to also specify the file name to access from Github Pages e.g. output file `example.html` can be accessed using URL [pokgak.github.io/citf-graphs/example.html](http://pokgak.github.io/citf-graphs/example.html) (link example only, not working).

Hope that clears up any confusion.

---

<div class="post-metadata">

**Author:** ![fatal\_shots](https://avatars.discourse-cdn.com/v4/letter/f/e68b1a/32.png) [@fatal\_shots](https://community.plotly.com/u/fatal_shots)\
**Post date:** [June 4, 2023, 3:21pm UTC](https://community.plotly.com/t/how-to-display-plotly-graph-on-github-pages/44398/5 "2023-06-04T15:21:45Z")

</div>

@pokgak Any idea how to display the plot using an iframe? I have an iframe that gets the HTML code from a file on my repo, but I get an error… Here’s an example of the HTML and the output on my GitHub Pages site:

```auto
<iframe src="https://raw.githubusercontent.com/s-lasch/s-lasch.github.io/main/_includes/scatter_matrix.html" 
        width="100%" 
        height="300px"></iframe>

```

 ![image_2023-06-04_112139905](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/8/2/8228943cda7a1e9537805e62ffa9918c8f03efc8.png)

I went into the console on my site, and this is the following output:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/2/3/23f169d857cc2dda5e89b542ed7f3690068a49b9.png)

---

<div class="post-metadata">

**Author:** ![fatal\_shots](https://avatars.discourse-cdn.com/v4/letter/f/e68b1a/32.png) [@fatal\_shots](https://community.plotly.com/u/fatal_shots)\
**Post date:** [August 22, 2023, 10:13pm UTC](https://community.plotly.com/t/how-to-display-plotly-graph-on-github-pages/44398/7 "2023-08-22T22:13:11Z")

</div>

If you’re having the same issues with putting a plotly graph in an HTML iframe, I found another solution that works. Since Github Pages serves these certain files as **text-type** , for my project, I had to look elsewhere. Using githack you can bypass GitHub pages’ lack of content-type serving.

Go to the website and paste in the link to the file from Github, in my case here:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/7/2/72d4c4837c78be3b2d5835c044acf8312e8f4fee.png)

I used the production link, as it gives a slight increase to privacy. Githack serves files **content-type** , so putting a link to the file will serve it without displaying the content of the file as regular text. [Here](https://steven-lasch.com/post/crania-data-viz/) is the link to the webpage I was having issues with, now fixed.
