All Projects → friends-of-hugo → contentful-export

friends-of-hugo / contentful-export

Licence: MIT license
Extract Contentful to Hugo

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to contentful-export

contentful-hugo
A CLI tool that pulls data from Contentful and turns it into markdown files for Hugo and other static site generators. It also includes an express server that can be used for local development and content previews
Stars: ✭ 31 (+40.91%)
Mutual labels:  static-site-generator, hugo, contentful
wowchemy-hugo-themes
🔥 Hugo website builder, Hugo themes & Hugo CMS. No code, easily build with blocks! 创建在线课程,学术简历或初创网站。#OpenScience
Stars: ✭ 6,891 (+31222.73%)
Mutual labels:  static-site-generator, hugo
Hugo
The world’s fastest framework for building websites.
Stars: ✭ 55,899 (+253986.36%)
Mutual labels:  static-site-generator, hugo
hugy
Hugy is an Electron desktop app acting as a GUI for the Hugo static site generator.
Stars: ✭ 44 (+100%)
Mutual labels:  static-site-generator, hugo
Post Scheduler
Schedule posts & content updates for static websites (Jekyll, Hugo, Gatsby, Phenomic etc)
Stars: ✭ 184 (+736.36%)
Mutual labels:  static-site-generator, hugo
Atlas
The Hugo boilerplate we use for our projects.
Stars: ✭ 232 (+954.55%)
Mutual labels:  static-site-generator, hugo
persian-hugo
Persian is a box design personal blog theme based on Bootstrap and powered by Hugo. It is very responsive and perfectly fits on any sized screen device.
Stars: ✭ 32 (+45.45%)
Mutual labels:  static-site-generator, hugo
Hugs
🤗 A super simple starting point for Hugo websites.
Stars: ✭ 162 (+636.36%)
Mutual labels:  static-site-generator, hugo
twenty-twenty-hugo
Twenty Twenty Hugo is forked from WordPress Twenty Twenty theme. It's fully functional like the WordPress theme.
Stars: ✭ 48 (+118.18%)
Mutual labels:  static-site-generator, hugo
liva-hugo
Liva is a personal blog template powered by Hugo.
Stars: ✭ 192 (+772.73%)
Mutual labels:  static-site-generator, hugo
neofeed-theme
A personal feed for Neocities, GitHub Pages, or anywhere else, built with Hugo. #IndieWeb friendly and all yours. It's better than Twitter.
Stars: ✭ 62 (+181.82%)
Mutual labels:  static-site-generator, hugo
Vanilla Back To Top
Simple and smooth Back To Top button
Stars: ✭ 179 (+713.64%)
Mutual labels:  static-site-generator, hugo
Hugo theme pickles
Modern, Simple and beautiful Hugo theme
Stars: ✭ 168 (+663.64%)
Mutual labels:  static-site-generator, hugo
Emacs Easy Hugo
Emacs major mode for managing hugo
Stars: ✭ 235 (+968.18%)
Mutual labels:  static-site-generator, hugo
Staticman
💪 User-generated content for Git-powered websites
Stars: ✭ 2,098 (+9436.36%)
Mutual labels:  static-site-generator, hugo
readme-in-static-site
💎 Transform and insert your GitHub readme in your static site.
Stars: ✭ 24 (+9.09%)
Mutual labels:  static-site-generator, hugo
Pendulum
A simple markdown editor for static files (Hugo, Nexo, Jekyll, MkDocs, ...)
Stars: ✭ 157 (+613.64%)
Mutual labels:  static-site-generator, hugo
Actions Gh Pages
GitHub Actions for GitHub Pages 🚀 Deploy static files and publish your site easily. Static-Site-Generators-friendly.
Stars: ✭ 2,576 (+11609.09%)
Mutual labels:  static-site-generator, hugo
potato-dark
Dark and elegant blog theme for goHugo static site generator.
Stars: ✭ 21 (-4.55%)
Mutual labels:  static-site-generator, hugo
hugofy-vscode
Hugofy is a plugin for Visual Studio Code to make life easier to use Hugo static site generator
Stars: ✭ 27 (+22.73%)
Mutual labels:  static-site-generator, hugo

Contentful Hugo Extractor

 

This tool extracts all content from your Contentful space and makes it easily consumable by Hugo. You can run it locally or as part of a CI server like Travis.

Install

Go Install Method

Assuming Go (1.10 +) is installed as well as dep

go get -u "github.com/friends-of-hugo/contentful-export"
cd "$GOPATH/src/github.com/friends-of-hugo/contentful-export"
dep ensure
go install

Usage

contentful-export [Flags]

Flags:
 -space-id=value      "Id of the contentful space from which to extract content. If not present will default to an environment variable named `$CONTENTFUL_API_SPACE`"
 -api-key=value       "API Key used to authenticate with contentful for content delivery. If not present will default to an environment variable named `$CONTENTFUL_API_KEY`. The preview API key should be provided if -p is used."
 -config-file=value   "Path to the config TOML file to load. Defauls to `./extract-config.tml`"
 -p                   "If present, the contentful preview API will be used so that draft content will be included as part of the export."

The tool requires two parameters to work, a contentful space id and API key. These can be provided as command line flags or as environment variables

As environment vars...

export CONTENTFUL_API_KEY=YOUR-CONTENT-DELIVERY-API-ACCESS-TOKEN-HERE
export CONTENTFUL_API_SPACE=YOUR-SPACE-ID-HERE

contentful-export

As flags...

contentful-export -space-id=[YOUR-ID-HERE] -api-key=[YOUR-ACCESS-KEY-HERE] -config-file="./export-conf.toml"

Expected output

Contentful Hugo Extractor stores all content under the /content directory. For each content type, it makes a subdirectory. For each item, it creates a markdown file with the all properties in TOML format.

Special cases:

  • Items of type Homepage are stored as /content/_index
    • Note that there can only be one such item
  • Fields named mainContent are used for the main content of the markdown file
  • File names are based on the ID of the item to make it easily referencable from related items (for the machine, not humans)

Configuration

Use the --config-file command line flag to provide the location of a TOML configuration to laod or ensure that there is a extract-config.toml file in the work directory of contentful-hugo

Configure YAML output

While the default output is in TOML format, it is also possible to output content in YAML format. Use the following key in your config file:

encoding = "yaml"

Configure Hugo Page Bundles

contentful-export will export each content type in contentful into its own content directory ./content/ and, since hugo treats each rootlevel content directory as a Section, you will end up having a hugo section for each contentful content type. Hugo allows you to provide Section level configuration for its Page Bundles by dropping a file named _index.md in the section's content directory. It is likely that you'll want to provide such configuration for some sections.

For example, let's say you need to make a section headless. Pretend that you have a contentful content type with the id question and you have some questions in your contentful content model which you intend to reference in a seperate FAQ page. After a contentful-hugo export, you might the following directory structure:

./
|   content
|   |   _index.md
|   |   question
|   |   |   12h3jk213n.md   //question 1
|   |   |   sdfer343sn.md   //question 2
|   |   page
|   |   |   sdf234dd32.md   //FAQ page - refs questions in its frontmatter
|   layouts
|   |   _default
|   |   |   single.html
|   |   page
|   |   |   single.html //question refs are loaded via .Site.GetPage

Without any further confuguration, hugo would generate a HTML file for the page using the ./layouts/page/single.html layout template but it would aslo generate HTML files for the questions using the ./layouts/_default/single.html layout template. To prevent this from happening you would create the following file under the path ./content/question/index.md:

+++
headless = true
+++

If you need this kind of configuration, the contentful-hugo export process can generate this index.md file for you. Simply provide the TOML to use in your config file:

encoding = "toml"
[section]
[section.question]
 headless = true

You can nest as many tables as you need under the [sections] and if the nested table name matches a contentful content type id than the configuration provided will be propagated to the section's index.md frontmatter.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].