is now part of CreativePro.com!

Turning Off Hyphenation for URLs

6

Beth wrote:

Any clever way you can think of to make InDesign recognize URLs so that it knows to never hyphenate them when breaking lines?

Well, we can’t make InDesign recognize URLs specifically, but we can give you a way to turn off hyphenation for a given string of text. Actually, there are a couple of ways.

First, you could apply the No Break style to the text. But that’s rather extreme, as it won’t let that chunk of text break from one line to another at all. That’s not helpful for long URLs, especially.

The second, more compassionate method, is to change the language of the text to [No Language]. After all, a URL isn’t really English (or Spanish or whatever), and you don’t want to spell-check it anyway. So setting it to No Language means that it won’t cause halts when checking your spelling, and InDesign simply stops trying to hyphenate it. Instead, long URLs break at the punctuation, or in the middle of a word if it’s really long.

If you need to specify a logical place for a long URL to break, you can insert a Discretionary Line Break.

By the way, how do you find all the URLs in your document? Well, one way is with GREP (CS3 and later). Keith Gilbert wrote up a nice method for this on his blog. You could, then, use that GREP to apply the no language designation. Or, in CS4, you could use GREP Styles to apply it automatically in the paragraph style.

David Blatner is the co-founder of the Creative Publishing Network, InDesign Magazine, CreativePro Magazine, and the author or co-author of 15 books, including Real World InDesign. His InDesign videos at LinkedIn Learning (Lynda.com) are among the most watched InDesign training in the world.
You can find more about David at 63p.com

Follow on LinkedIn here
  • Phyllis says:

    Fantastic tip! I now have a “No Language” character style set up in my default basic character styles (since I’ve had this problem many times). So I’ll be using that tip a lot… :-)

    Thanks!
    Phyllis

  • Phyllis says:

    “Instead, long URLs break at the punctuation, or in the middle of a word if it?s really long.”

    As far as I can tell, it *doesn’t* break in the middle of the word, but only at the punctuation. But that’s fine as I’m planning to add discretionary line breaks to all of mine. Takes a little while but will improve the results as I’m forever having the text reflow and cause problems with the URLs. Also, the discretionary line breaks will help me follow the style-manual rules of breaking the URL *before* the dot in .com, etc.

    So I set up a keyboard shortcut for discretionary line break…. :-)

  • @Phyllis: Try a really, really long URL. I agree that a disc-linebreak kbsc is the best idea, though.

  • Phyllis says:

    Hey, I just made up a really long one and that worked. But a short one (like https://creativepro.com) will overset rather than break anywhere other than at the punctuation (at least on mine). Weird.

    It’s a great tip though, so thanks! And I enjoyed the InDesign seminar yesterday!!!!!

  • Donna says:

    Hi

    We publish books that include at times, thousands of listings that include URLs. We’ve been looking for ways to eliminate the manual breaking of URLs.

    The discretionary line break works great, but not in all cases. We search out the @ and put the dlb after it. I’ve experimented a bit and find that if you use the Adobe Paragraph Composer in the justification, it works much better. I also created a character stylesheet for .com where I applied “no break” . I searched and replaced all .coms and it worked. You could probably just search the period if you want to get them all.

    If any of you use Indata to import databases, there is a string you can write to break them automatically at the @ if you reach a certain amount of characters in a line. Because many of our URLs are indented on the second line, with this string, you can put a return after the @ and insert a tab.

  • Elsabe says:

    Thanks indeed!!

  • >