# After import of EPUB file internal hyperlinks are broken

**URL:** <https://pressbooks.community/t/after-import-of-epub-file-internal-hyperlinks-are-broken/2384>\
**Category:** Developer Questions\
**Created:** [March 30, 2023, 12:22pm UTC](https://pressbooks.community/t/after-import-of-epub-file-internal-hyperlinks-are-broken/2384 "2023-03-30T12:22:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![t.dumm](https://pressbooks.community/user_avatar/pressbooks.community/t.dumm/32/134_2.png) [@t.dumm](https://pressbooks.community/u/t.dumm)\
**Post date:** [March 30, 2023, 12:22pm UTC](https://pressbooks.community/t/after-import-of-epub-file-internal-hyperlinks-are-broken/2384/1 "2023-03-30T12:22:39Z")

</div>

If I import an EPUB into Pressbooks, the internal hyperlinks that are correctly working in the EPUB file are not correct in Pressbooks anymore.

This is because filenames and paths (chapter, front-matter, back-matter) are not the same in Pressbooks as in the EPUB.

What is the proper way to import EPUB, such that the internal hyperlinks are still working in Pressbooks?

Issue could be related to the following statement in the file[/inc/modules/import/epub/class-epub201.php](https://raw.githubusercontent.com/pressbooks/pressbooks/dev/inc/modules/import/epub/class-epub201.php)

```auto
/**
	 * Change hrefs
	 *
	 * @param \DOMDocument $doc
	 * @param string $type front-matter, part, chapter, back-matter, ...
	 * @param string $href original filename, with (relative) path
	 *
	 * @return \DOMDocument
	 */
	protected function kneadHref( \DOMDocument $doc, $type, $href ) {

		// TODO: Fix self-referencing URLs

		return $doc;
	}

```

---

<div class="post-metadata">

**Author:** ![t.dumm](https://pressbooks.community/user_avatar/pressbooks.community/t.dumm/32/134_2.png) [@t.dumm](https://pressbooks.community/u/t.dumm)\
**Post date:** [April 15, 2023, 12:17am UTC](https://pressbooks.community/t/after-import-of-epub-file-internal-hyperlinks-are-broken/2384/2 "2023-04-15T00:17:01Z")

</div>

Maybe the code that is missing in the TO-DO above can be derived from the function **fixInternalLinks** of the cloning routine [pressbooks/class-cloner.php at dev · pressbooks/pressbooks · GitHub](https://github.com/pressbooks/pressbooks/blob/dev/inc/cloner/class-cloner.php)

I am not a coder. If anybody is willing to fix this, I am willing to pay for the job.

---

<div class="post-metadata">

**Author:** ![t.dumm](https://pressbooks.community/user_avatar/pressbooks.community/t.dumm/32/134_2.png) [@t.dumm](https://pressbooks.community/u/t.dumm)\
**Post date:** [May 15, 2023, 6:48am UTC](https://pressbooks.community/t/after-import-of-epub-file-internal-hyperlinks-are-broken/2384/3 "2023-05-15T06:48:44Z")

</div>

My collegue fixed the issue and placed a pullrequest:

> <https://github.com/pressbooks/pressbooks/pull/3314>
>
> @see https://pressbooks.community/t/after-import-of-epub-file-internal-hyperlink…s-are-broken/2384
