WordPress.org

Ready to get started?Download WordPress

Forums

Internal linking best practice? (5 posts)

  1. jmstovall
    Member
    Posted 5 years ago #

    Hi all,

    I've done a bit of hunting on this and haven't come up with any conclusive opinions (if there are any), but I want to know, now that we're at 2.7, if there's a "best practice" for internal linking?

    Many of the instructions I find tell people to go to the page they want, copy the URL, and paste it in the ahref. I'm a little surprised by this...putting that full URL to an internal page seems to violate the idea of simplicity, and I also assume would break if the link structure changed at any point.

    Soooo....am I right, and we're still depending on plugins to simplify our internal links? Or does 2.7 support a linking function I haven't found yet? Is there an "accepted" way to do this that is developer and SEO friendly?

    Let me know what you think, and thanks much for the help!

    -j

  2. stvwlf
    Member
    Posted 5 years ago #

    relative links don't work well in WP or CMS's because the location from which they are accessed changes depending on what part of your site the page is opening from and how you have permalinks and folder layout set up. This leads to 404's in certain places.

    One way to do it is
    <?php bloginfo('url'); ?>/my-single-page
    and <?php bloginfo('url'); ?>/category/shoes/my-single-page

    if i have WP installed in folder domain.com/site, i tend to use
    href="/site/my-page"

  3. jmstovall
    Member
    Posted 5 years ago #

    Ok, so using some sort of plugin to manage that is probably best?

    WP is the most dynamic CMS I've worked with. The others have been much more "static-y", roll-your-own solutions.

  4. stvwlf
    Member
    Posted 5 years ago #

    The main navigation links in WP are generally handled with the function called wp_list_pages() - that is what paints the nav in most themes.

    You might want to look at the code it generates to get an idea of how to do it.

    An advantage of <?php bloginfo('url') is that if you later change the URL of your WP install, change domains, or whatever, the links are not broken

  5. jmstovall
    Member
    Posted 5 years ago #

    Ah, I see what you're saying now. I will play this weekend. Thank you much!

Topic Closed

This topic has been closed to new replies.

About this Topic