├── .gitignore
├── Gemfile
├── _layouts
├── article.html
└── default.html
├── de
└── index.html
├── index.html
├── _includes
└── nav.html
├── _config.yml
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | _site
2 | .sass-cache
3 | Gemfile.lock
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 | gem 'contentful'
3 | gem 'jekyll'
4 |
5 | group :jekyll_plugins do
6 | gem "jekyll-contentful"
7 | end
8 |
--------------------------------------------------------------------------------
/_layouts/article.html:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | ---
4 |
5 | {{ page.title }}
6 | {{ page.contentful_fields.body | markdownify }}
7 |
8 |
--------------------------------------------------------------------------------
/de/index.html:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | contentful_locale: de-DE
4 | contentful_id: "home"
5 | ---
6 |
7 |
Artikel
8 | {% include nav.html %}
9 |
10 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | contentful_locale: en-US
4 | contentful_id: "home"
5 | ---
6 |
7 |
Articles
8 | {% include nav.html %}
9 |
10 |
--------------------------------------------------------------------------------
/_layouts/default.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | jekyll-contentful-example
6 |
7 |
8 | {{ content }}
9 | {% language_switcher %}
10 |
11 |
--------------------------------------------------------------------------------
/_includes/nav.html:
--------------------------------------------------------------------------------
1 |
2 | {% for p in site.pages %}
3 | {% if p.title and page.contentful_locale == p.contentful_locale %}
4 | -
5 |
8 |
9 | {% endif %}
10 | {% endfor %}
11 |
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | # Site settings
2 | title: Your awesome title
3 | email: your-email@domain.com
4 | description: > # this means to ignore newlines until "baseurl:"
5 | Write an awesome description for your new site here. You can edit this
6 | line in _config.yml. It will appear in your document head meta (for
7 | Google search results) and in your feed.xml site description.
8 | baseurl: "" # the subpath of your site, e.g. /blog/
9 | url: "http://yourdomain.com" # the base hostname & protocol for your site
10 |
11 | # Build settings
12 | markdown: kramdown
13 | contentful:
14 | preview: Yes
15 | production_access_token: 'YOUR_PRODUCTION_TOKEN'
16 | preview_access_token: 'YOUR_PREVIEW_TOKEN'
17 | space: 'YOUR_SPACE_ID'
18 | published_locales_field: "published_languages"
19 | localization:
20 | - locale: en-US
21 | url_prefix: ""
22 | lang: "English"
23 | - locale: de-DE
24 | url_prefix: "de/"
25 | lang: "Deutsch"
26 | content_types:
27 | - "ARTICLE_CONTENT_TYPE_ID"
28 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Example Jekyll site using Contentful.com
2 |
3 | This is a minimal example of a jekyll site using the [jekyll-contentful gem](https://github.com/dommmel/jekyll-contentful) to pull content from contentful.com at build time.
4 |
5 | The example also demos the i18n features of the gem.
6 |
7 | ## Running the example
8 |
9 | At contentful.com
10 |
11 | 1. Create a contentful.com account and a space (if you don't have one already)
12 | 2. Add a the "de-DE" locale to the space (Settings -> Locales)
13 | 3. Create a content type "Article".
14 | 4. Add a short text field with the ID "title" to the content type. Make sure to check "This field represents the Entry title" and "enable localization of this field" on the field's settings page.
15 | 5. Add a long text field with the ID "body". Check the checkbox "enable localization of this field" on the field's settings page.
16 | 4. Create at least one entry (better more, and preferably translate them as well)
17 |
18 | On your machine
19 |
20 | 1. Clone the repo and ``cd`` into the folder
21 | 2. Change ``_config.yml`` to include your Contentful API keys, Space ID, Content Type ID
22 | 3. Run ``bundle install`` to install the dependencies
23 | 4. Run ``bundle exec jekyll serve -w`` to build and serve the site
24 | 5. Visit [http://127.0.0.1:4000](http://127.0.0.1:4000) to view the site you just built.
--------------------------------------------------------------------------------