![]() Now, we are going to set up a webhook on Contentful so that it will trigger Codeship to create a ‘new’ build. But what about when I update my content in Contentful? Well onto the last step. Now that Codeship is all set up, any time you make a commit to Github, Codeship will create a new build of your Middleman project and deploy to S3. One quick note, if you do not have your AWS access key and secret key set up in your project, you will have to input them in the Environment Variables section in Codeship so that it can be pushed up to the S3 bucket. Input our S3 command by selecting the custom script option and then inputting: # Compile the project bundle exec middleman contentful bundle exec middleman build # Deploy site to S3 bucket bundle exec middleman s3_sync ![]() In the Test section, under Setup commands, I use this: # Use Ruby 2.2.0 rvm use 2.2.0 # Install PNGOUT (used by middleman-imageoptim) wget tar -xzf pngout-* mv pngout-*-linux/x86_64/pngout ~/bin # Install dependencies specified in Gemfile bundle installįor the deployment section, we are going to set up our s3_sync command so that Codeship will push our site live to our S3 bucket. There are two sections we are going to worry about in Codeship. Make sure you push your project to Github so that Codeship can have access to it and select the repo for use in Codeship. Go to and sign up for an account (I prefer to sign up with my Github account to make it easy). Well now we are going to setup Codeship so that we can have a fully functional CMS that will update whenever the content is saved in Contentful, so that we don’t have to run our middleman contentful command every time. See the code below on how I looped over the projects I created: Projects In your HTML template file (I use ERB), you now have access to that data file so you can loop over your data. So your probably asking yourself, so I have to do this every time to pull in new data….well keep reading. You should now see a folder called ‘data’ in your project with a YML file within that will have all of your posts within that file. Type in the following command in your terminal: bundle exec middleman contentful Go to Entries on Contentful, and include some content in your content type so that we can pull that data into the Middleman project. config.rb activate :contentful do |f| f.access_token = ‘ACCESS TOKEN PLACED HERE’ f.space = end 3. You will need to input your access token which can be found by clicking on API’s from the top nav menu, then clicking API keys on the left hand side. ![]() We are now going to set up Contentful Middleman to pull in our data. Once created, click the JSON preview and find the ‘Space’ ID. Gemfile gem 'middleman', '~> 3.4.1' gem 'middleman-livereload' gem 'middleman-s3_sync' gem 'contentful_middleman' 2.Ĭreate a content type in Contentful (I called mine Projects). If you have never used Contentful before, it is a CMS API which you can basically make calls to pull data - pretty awesome. ![]() Include the Middleman Contentful gem into your project, bundle install and sign up for Contentful. Here are the steps to get your project all set up: 1. Hopefully you already have your Middleman project set up and hosted on S3, but if not checkout this article: By using Middleman to generate my website, Contentful for my CMS and Codeship for my deployment & builds, I can now create fully-editable ‘static’ websites for clients. Well I have come up with a workflow so you can build a full-scale website that has a CMS and updates when new content is entered. The only problem is, most clients want to edit their content and it’s pretty difficult to do when a website is completely static. ![]() Lately I’ve been wanting to take Middleman into my professional work flow and use it for building websites for clients. If you are code savvy, it is a great way to build marketing websites, blogs and even dev centers. It gives you the opportunity to use templates, SCSS, gems and even local reloading on save. Middleman allows you to build static websites with modern day development tools. How to use Contentful, Codeship and Middleman to build a ‘Static Website’ with a CMS hosted on Amazon S3 ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |