When I started this blog, I wanted to try and automate as much as possible, hopefully to save me time and make it easier to maintain. To be truthful, I was considering WordPress as my blogging platform at one time because of the awesome community around it.
I don't want to get into a debate about which blogging platform is better or why I decided on Sitefinity, but the truth was WordPress has a ton of great extensions. One of the extensions that I really liked was the ability to post to Twitter when a blog post went live.
So I started snooping around Sitefinity looking for an easy way to post content from my blog to Twitter. The solution I came up with is actually really simple and requires no code. I also created a short video below and provided the exact instructions on how you can also set it up on your blog.
Also, I didn't mention this in the video, but you can apply this same concept to almost any other module in Sitefinity. For example, you could set this up for the events module and every time a new event goes live on the Internet, it will also post to your corporate Twitter page. Nice.
Anyways, enough chatter, get all the details below and enjoy.
Configure Twitter in Sitefinity
First, you need to configure Sitefinity with your Twitter account. You will need to be part of the Administrators role in Sitefinity to complete these steps.
- Log on to Sitefinity back-end.
- Go to Administration > Settings. If the multi-site module is enabled you will need to click on the Global Settings link.
- Click the Twitter menu item on the left.
- Under the section "Added Twitter applications", click the Actions menu and select the "Associate Twitter User".
- If you need to, log on to Twitter, and then click the "Authorize app" button. After a few seconds you will return to the Twitter settings page and your Sitefinity account will be associated in Sitefinity.
Create the Twitter Post Field
Next, you will create a separate field for the blog post content type to post on Twitter. This step isn't required because you could just as easily post the "Title" to your Twitter feed, but I wanted to have more control over what message was getting posted.
- Go to Content > Blogs.
- Click on any one of the blogs listed. If there are no blogs listed, create a new blog.
- Click the link "Custom Field for posts" under Settings for blogs. You will need at least one blog post created before the links will be available via on the right.
- Under the section labeled "Custom fields" click the "Add a field..." button.
- On the "Add a field" dialog set the following attributes and click continue.
- Type: Short text
- Name: TwitterPost
- This is a hidden field: unchecked
- Interface widget for entering data: Textbox
- DB Length: 140
- Allow empty values: checked
- Include in indexes: unchecked
- Set the additional settings for the new Twitter Post field.
- Label: Twitter Post
- Instructional text: The tweet must be 140 characters or less. This includes the content plus the link.
- Make required: checked
- Range Min: 1 characters
- Range Max: 124 characters
- Click the Done button to add the new field to the blog posts content type.
You might be wondering why I set the Max number of characters to 124 and not 140 characters. This is because bit.ly will create shortened links about 14 characters long, but I am adding 1 additional character just in case 15 characters links are used and 1 character for a space. 140 minus 16 is 124 characters for content and 16 for the shorten link.
Configure the Twitter Post Feed
Now you just need to configure the Alternative Publishing settings to push the content out to Twitter. This part gets a little confusing so I broke it up into four sections.
Set Basic Settings
- On the Sitefinity back-end, go to Administration > Alternative Publishing.
- On the Feeds & Notifications screen click the "Create a feed" button.
- On the Create a feed screen set the Title to "Tweet Blog Posts on Twitter"
- Check the box labeled "This feed is Active"
Set Advanced Options
- Under Advanced options click the button "Change Data structure..." under the Data section.
- Click the "Add a data field" button
- Set the Title and Name fields to "TwitterPost". This is the same field name you used for custom field you created for the blog post.
- Set the Max length field to 140
- Click the "Save changes" button.
- On the "Create a feed " screen under Advanced options set the Feed type to "Pass through".
Set the Content to Include
- Under "Content to include" remove any existing content types and then click "Add another content type" and set the following settings.
- Select "Sitefinity content" to include.
- Set the content type to "Blog Posts"
- Which blog posts to display?: From all blogs (this is up to you what you want to include)
- Set "Page where the content is published" to the main page that will be displaying your blog posts.
- Set the the Mappings, click the "Mapping Settings" button.
- Look for the new you added to your data structure, in this case we called it "TwitterPost", click the link "Add a mapping".
- In the drop down box select the field from the blog post content type, in the case it is called "Twitter Post".
- The click the "Accept changes" button and then click the "Done" button in the Content to include screen.
Set the Publish As Settings
- Under "Publish as..." remove any existing content types and then click "Add more..."
- Click Twitter feed open to publish too.
- Under the section labeled "Which Twitter application to use?" select the twitter application you configured earlier, in this case it was called "Sitefinity".
- Under the section labeled "Which Twitter user to use?" select the Twitter account you associate to Sitefinity, in this case my account name is "codeengagett".
- Click the button labeled "Mapping Settings". This is where you will specify the content and link for the tweet.
- Set the field "Content" to your Twitter post field. In my case it is called "TwitterPost".
- Leave the Link field to its default and click the "Accept changes" button and then click the "Done" button in the Content to include screen.
- Finally, click the "Save changes" button in the "Create a feed" screen to active the new feed.
Setup bit.ly URL Shortening
Finally, if you haven't done so already, I highly suggest setting up bit.ly URL shortening so that you can shorten all your URLs for Twitter. This will save you characters since you only have 140 them in total for each post. Also, setting up bit.ly gives you one other benefit, tracking URL clicks for the shortened URLs. Below are the general steps that can help you get this setup quickly.
- Go to https://bitly.com an login. If you don't have a bit.ly account, create one and login.
- In the upper right, click on your username and select the "Settings" menu item from the drop down menu.
- On the "Settings" page clicked the "Advanced" tab.
- Scroll down to the bottom of the page, under the section "Legacy API Key" copy the Login value and the API Key value.
- Login to your Sitefinity backend, then go to Administration > Settings.
- Click the "Twitter" menu item on the left.
- Under the section "URL Shortening" click the edit link.
- Set the Account Login and API Key, then click the Save button. Now your links for Twitter will be shortened automatically.
Armed with this information, you can now post to Twitter directly from Sitefinity without writing a single line of code or adding any custom modules. That's pretty darn cool and not even Word Press can do that without downloading a custom extension.
To conclude, I would like to ask, what kind of mash up do you think you could build with Sitefinity and Twitter? I made some suggestions in this blog post, but I want to hear from you an if possible I would like to see what kind of solutions you have implemented.
Craig out :-)