Why Twitter share is not working with your test server website links

Was trying to wrap my head around why the twitter share URL was not working on the test server, as it would say the tweet is too long even though the url should be shortened by Twitter automatically.  It seemed I had to use wp_get_shortlink() or a bit.ly link rather than the full URL.

Turns out it was due to the URLs being local.wordpress.dev (the default through VVV, a popular local WordPress vagrant script), and Twitter wouldn’t automatically shorten it.

Does not auto shorten with development (.dev) domain

Does not auto shorten with development (.dev) domain

Twitter takes shortened length of URL into account with .com

Twitter takes shortened length of URL into account with .com

 

Not that you should be sharing development URLs anyway, at least now you know it’ll work on a live server.  Unless you have a valid top level domain like .black which Twitter won’t shorten, either.

.black won't get shortened even though it's perfectly valid

.black won’t get shortened even though it’s perfectly valid