• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.1 SEO: Handling external links

#1
I've noticed that in my posts when a user posts a link to an external link, rel='external nofollow' is not attached to links. Since my domain is high ranking, spammers see this as a dangling carrot.

What is the best way to handle external links in xenForo?
 

Jake Bunce

XenForo moderator
Staff member
#4
I've noticed that in my posts when a user posts a link to an external link, rel='external nofollow' is not attached to links. Since my domain is high ranking, spammers see this as a dangling carrot.
That would deter spammers, not attract them. Their spam links will carry no weight with search engines. You want to change this?

@brogan, is there a way to turn this on for all external links?
You want to make staff links nofollow as well? Edit this file:

library/XenForo/Model/User.php

Add the red code:

Code:
	/**
	 * Prepares a user record for display. Note that this may be called on incomplete guest records.
	 *
	 * @param array $user User info
	 *
	 * @return array Prepared user info
	 */
	public function prepareUser(array $user)
	{
		if (empty($user['user_group_id']))
		{
			$user['display_style_group_id'] = self::$defaultGuestGroupId;
		}

		$user['customFields'] = (!empty($user['custom_fields']) ? @unserialize($user['custom_fields']) : array());

		// "trusted" user check - used to determine if no follow is enabled
		$user['isTrusted'] = (false && !empty($user['user_id']) && (!empty($user['is_admin']) || !empty($user['is_moderator'])));

		if (XenForo_Visitor::hasInstance())
		{
			$user['isIgnored'] = XenForo_Visitor::getInstance()->isIgnoring($user['user_id']);
		}

		return $user;
	}
That will remove the exception for admins and mods which will cause all hyperlinks in user content to be "nofollow".

edit - this can be made into an addon by extending XenForo_Model_User.