View Full Version : Links to URLs work, internal links don't?


NewDay
10-19-2010, 11:24 AM
I have a ton of hyperlinks in a single doc that all refer to different locations within the doc. Upon uploading to iBooks (via my own desktop, iTunes) I see that these don't work, though they look as if they should. Epub validator brings back the dreaded Error message referencing the anchors, "fragment identifier is not defined." Hyperlinks connecting to URLs work just fine. What gives and how can I fix it?

charleski
10-19-2010, 11:51 AM
A whole load of things could have happened, impossible to be sure as you don't show us any code. My guess is your epub has been split into separate files and the links fail to specify the relevant file as well as the fragment id.

NewDay
10-19-2010, 12:25 PM
Be back with the code in a couple of hours. Really appreciate your help.

NewDay
10-19-2010, 04:19 PM
OK, here's the error message, followed by the code in the xhtml file it refers to:
'abalone-chowder-anchor': fragment identifier is not defined in 'OEBPS/Cast Iron Cuisine ePub-48.xhtml'

They make an excellent<span class="link-style"><a href="#abalone-chowder-anchor"> Abalone Chowder</a></span>.)</p>

NewDay
10-19-2010, 04:31 PM
Another example:
error message: 'dried-wild-mushrooms-anchor': fragment identifier is not defined in 'OEBPS/Cast Iron Cuisine ePub-48.xhtml'
code in 48.xhtml: <p class="ingredients" xml:lang="en-us">1 cup dried chanterelle mushrooms (see <span class="link-style"><a href="#dried-wild-mushrooms-anchor">Resources</a></span>)</p>

charleski
10-19-2010, 09:47 PM
href="#abalone-chowder-anchor"
href="#dried-wild-mushrooms-anchor"

These aren't specifying a file before the fragment id. From the spurious lang attribute I'm guessing you've exported this from InDesign and run into InDesign's link bug. Try exporting it without checking the box which splits it at first-level headings, though that means you'll need to use Sigil to do the ToC.

NewDay
10-20-2010, 12:27 AM
Had a hunch it was an InDesign bug. More than a few I've encountered in CS5. And then there are the iBook bugs. Anybody got a good can of bug spray?
Thanks, charleski. Appreciate the input.

Adjust
10-20-2010, 06:09 AM
Yeah Charleski is correct.
Is isn't an iBooks bug though, it a CS5 issue
All the links will work going there, but the return trip back all the links will be broken.
you can run a search and replace on the xhtml files to fix this though, it only take a few minutes.

For example I had one with hundreds and hundreds of footnote/endnotes. all the links from the text to the "notes" worked but the going from the "notes" file back to main text were broken...

you just need to insert the correct xhtml file before the #

href="filename.xhtml#dried-wild-mushrooms-anchor"

Valloric
10-20-2010, 07:34 AM
href="#abalone-chowder-anchor"
href="#dried-wild-mushrooms-anchor"

These aren't specifying a file before the fragment id. From the spurious lang attribute I'm guessing you've exported this from InDesign and run into InDesign's link bug. Try exporting it without checking the box which splits it at first-level headings, though that means you'll need to use Sigil to do the ToC.

Wait, you're telling me that InDesign will split files without updating links? That's absolutely insane. It makes any file-splitting feature completely and utterly useless.

charleski
10-20-2010, 10:10 AM
The shameful fact is that InDesign CS5 has received 3 patches since it was launched and this bug still isn't fixed - it's still there in 7.0.3. Adobe was informed of the bug back in May, so you get the feeling that they don't really care about InDesign's epub export facilities.

Then again, InDesign really is focussed on print production - there are far better tools for creating reflowable formats and publishers need to get out of the habit of correcting galley proofs.

NewDay
10-20-2010, 11:37 AM
That's not the only CS5 bug, and I agree with you, charleski, it's absolutely shameful and irresponsible of Adobe not to have this software up to the task of correctly outputting epub files. Why should we have to chase our tails fixing code they should have gotten right in the first place? Epub book designers have better things to do.

NewDay
10-20-2010, 11:42 AM
Adjust, thank you very much. I'm gonna go try that right now. Sure glad you guys are out there to ask.

NewDay
10-20-2010, 01:17 PM
Adjust, I tried inserting the correct xhtml file as you expressed it and as my files gave it, but it's still not connecting. I must have missed something. What am I doing wrong here?

<a href="Cast Iron Cuisine ePub-48.xhtml#short-ribs-of-beef-anchor">Short Ribs of Beef</a>

<a href="Cast Iron Cuisine ePub-53.xhtml#mountain-bread-33-anchor">Mountain Bread</a>

Jellby
10-20-2010, 01:34 PM
Having filenames with spaces is possible, but it's asking for trouble (as is having non-ASCII characters). It might be that the files use "%20" instead of a space or something like that.

NewDay
10-20-2010, 01:43 PM
Jelby, I took the file designation literally, stroke by stroke, from the xhtml files as they are expressed in the OEBPS. Should I add hyphens between words in the file name?

NewDay
10-20-2010, 02:26 PM
Jellby, I tried substituting the %20 between words in the file name. No luck. What am I doing wrong here? It gives me "referenced resource missing in package" whether I add hyphens between words, run them all together, or add the %20. ???

charleski
10-20-2010, 06:39 PM
ADE-based readers can handle filenames with spaces without any problem, but iBooks can't. You can fiddle around adding %20s, but the easiest thing is just to remove spaces from the filename.

Adjust
10-20-2010, 07:08 PM
Yeah the problem is you have to treat iBooks as a new completely different reader, insofar as it refuses to follow the ePub specs which everyone else does, case in point, sans-serif fonts inside div, span, p classes...

Once you get it to work and know all the idiosyncrasys of the iBooks, the other readers will fall into place...

eg. this goes from the text to the Notes.xhtml file
<a id="anchor-50-anchor" /><span class="superscript"><a href="Notes.xhtml#anchor-57-anchor">1</a>

This goes from the Notes back to text file
<a id="anchor-57-anchor" /><p class="x-notes-text"><span class="superscript"><a href="Chapter_6.xhtml#anchor-50-anchor">1</a>

NewDay
10-20-2010, 09:12 PM
I see you used an underscore between Chapter and 6. Makes sense, 'cause then it reads as one without the confusion of words running together.

Adjust
10-20-2010, 09:26 PM
Yes, but that's for my own sanity more then anything else. I just don't like seeing the %20 in the code...

Another way to write the name without the spaces is by using capitals, for example

forexamplethislineishardtoread...ComparedWithThisL ine

NewDay
10-20-2010, 10:52 PM
I like your underscores better.

charleski
10-21-2010, 01:26 AM
Jellby, I tried substituting the %20 between words in the file name. No luck. What am I doing wrong here? It gives me "referenced resource missing in package" whether I add hyphens between words, run them all together, or add the %20. ???

You'll need to change the filenames in the opf file as well.

Fabe
10-21-2010, 02:34 PM
Jelby, I took the file designation literally, stroke by stroke, from the xhtml files as they are expressed in the OEBPS. Should I add hyphens between words in the file name?

1. My File Name Here Now - original
2. My_File_Name_Here_Now - good practice
3. My%20File%20Name%20Here%20Now - typical output for spaces

-Fabe

NewDay
10-22-2010, 10:39 AM
Fabe, thank you. Nice presentation.

wannabee
10-23-2010, 03:56 AM
Wait, you're telling me that InDesign will split files without updating links? That's absolutely insane. It makes any file-splitting feature completely and utterly useless.

It's just easier to stay with CS4. (CS5 was a waste, seeing as it was purchased explicitly for ePub export) CS4 doesn't wreck the links. I call the file names exactly what I want in the TOC and let InDesign create the TOC from the files names. CS4 replaces the spaces with %20 to all the code and it works fine.

NewDay
10-23-2010, 07:54 PM
I want my money back!

Adjust
10-24-2010, 06:57 AM
The one good thing I use it for, is for epubs with alot of images.
CS3 tends to repeat all the images used in the job depending on how many chapters there were... CS5 cleans them out

NewDay
10-25-2010, 11:59 PM
Clever ploy, Adjust. btw, I overcame that linking problem by establishing a category of "finder" (in this case, Recipe Finder) that used internal hyperlinks within the same file. That overcame the losing-them-across-files problem, and streamlined the nav toc to boot.

wannabee
10-26-2010, 09:33 AM
Clever ploy, Adjust. btw, I overcame that linking problem by establishing a category of "finder" (in this case, Recipe Finder) that used internal hyperlinks within the same file. That overcame the losing-them-across-files problem, and streamlined the nav toc to boot.

What sort of magic is that? Where is it learned? Who do you have to pay? But multiple files for the chapters right?

NewDay
10-26-2010, 11:29 AM
It's called Fiddle-and-Fix-It. This is a cookbook. Cookbooks need good indexes. Best index for an ereader is hyperlinks. Mention a recipe and Bang! hyperlink takes you right there.

Links across chapters still didn't work, but here's what I did finally get to function: The whole cookbook is in one document, but InDesign split the files according to chapters (Breakfast, Lunch, Dinner, Side Dishes, Cookies, Dessert, Dog Treats...you get the idea). Each chapter is a Level One heading in the toc.

Back at the Fiddle-and-Fix-It level, at the beginning of each chapter I created a rubric called Recipe Finder, which I gave a Level 2 heading. Breakfast chapter begins with a very brief discussion on the first page, then on the second page we find Breakfast Recipe Finder, which lists the breakfast recipes alphabetically, with a hyperlink to each recipe within that chapter (file). The toc reads heirarchically: Breakfasts, Breakfast Recipe Finder; Lunches, Lunch Recipe Finder; and so on.

Now if I can just find how to get the toc to actually STACK level two underneath level one, I'll be going live with this. Right now, iBooks is blithely ignoring my h1, h2 commands. Anybody got any ideas?

NewDay
10-26-2010, 03:31 PM
OK, seems the issue is an iBooks one. Add too many items (of any level) to the toc and it's anybody's guess what the toc will actually come out looking like.

So I streamlined the toc by making everything Level 1 and folding the Recipe Finder in with the chapter title, e.g. Breakfasts (with Recipe Finder), Lunches (with Recipe Finder), and so forth. Same function, less prolix. Fits on one page, too.

I just sent this puppy live. Probably sleep better tonight.

Keep the faith, fellow adventurers!

:thanks:

wannabee
10-26-2010, 07:26 PM
That's a good compromise. Have you got square eyes yet? I've just done a book with 94 recipes in it and they all borrow from one another so the book links to them from the TOC and a Recipe Page and each recipe to other recipes. I even put the glossary and another chapter that lists all the ingredient items in it. So the iBook TOC can handle many items in the list without breaking.

Adjust
10-26-2010, 07:42 PM
Yes, it is a real hit and miss kind of process this epub creation... not helped by dodgy CS releases...and the lack of decent learning material out in the internets...

Welcome "wannabee" from another Australian... you'll find a heap of good information here...

wannabee
10-26-2010, 09:01 PM
Yes, it is a real hit and miss kind of process this epub creation... not helped by dodgy CS releases...and the lack of decent learning material out in the internets...

Welcome "wannabee" from another Australian... you'll find a heap of good information here...

You betcha' Adjust . . . I landed a job as an eBook maker. I had never made an eBook. The day before the interview I devoured as much of this site as I could and made an ePub during the interview. No one else who applied had made an eBook either but they weren't game to jump on the PC during the interview. Got the job thanks the this forum. Still learning new tricks. Mainly from this forum and members links. Worth it's weight in ePubs.

NewDay
10-26-2010, 10:05 PM
Wow! Talk about courage!

Adjust
10-27-2010, 02:30 AM
You betcha' Adjust . . . I landed a job as an eBook maker. I had never made an eBook. The day before the interview I devoured as much of this site as I could and made an ePub during the interview. No one else who applied had made an eBook either but they weren't game to jump on the PC during the interview. Got the job thanks the this forum. Still learning new tricks. Mainly from this forum and members links. Worth it's weight in ePubs.

Nice going there wannabee...I've had plenty of help from people here, for sure...who you working for? hope it's working out for you.

wannabee
10-27-2010, 05:09 AM
A health organization with a stable of books that need to be made into eBooks. See my post. . .http://www.mobileread.com/forums/showthread.php?t=95975