# Merge HTML Files in Python

> Merge multiple HTML files in Python and export the combined content as a single HTML5 document.

Source: https://products.aspose.com/slides/python-net/merge/html-to-html/
Updated: 2026-07-27



## Merge HTML Files Using Aspose.Slides

[*Aspose.Slides for Python via .NET*](/slides/python-net/) lets you import multiple HTML documents into one `Presentation` and export the combined slides as a single HTML5 document. Use `SlideCollection.add_from_html` to import each HTML stream, then call `Presentation.save` with `SaveFormat.HTML5`.

## Merge HTML Files in Python

Create a `Presentation`, import the source HTML files in order, and save the combined content as an HTML5 document.

### Python code for merging HTML files into an HTML5 document

```python
html_file_paths = ["first.html", "second.html"]

with slides.Presentation() as presentation:
    presentation.slides.remove_at(0)

    for file_path in html_file_paths:
        with open(file_path, "rb") as html_stream:
            presentation.slides.add_from_html(html_stream)

    presentation.save("merged.html", slides.export.SaveFormat.HTML5)
```

## How to Merge HTML Files in Python

Follow these steps to combine multiple HTML files into one HTML5 document.

Install [*Aspose.Slides for Python via .NET*](/slides/python-net/).

Import the `aspose.slides` module in your Python project.

Create a `Presentation` and remove its default blank slide.

Open each HTML file and pass its stream to `SlideCollection.add_from_html`.

Call `Presentation.save` with `SaveFormat.HTML5` to create the merged HTML document.

## Merge Other Files
