Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

contentful-hugo

Package Overview
Dependencies
Maintainers
1
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

contentful-hugo

Node module that pulls data from Contentful and turns it into markdown files for Hugo. Can be used with other Static Site Generators, but has some Hugo specific features.

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
87
increased by1.16%
Maintainers
1
Weekly downloads
 
Created
Source

Contentful Hugo

This is a simple Node.js CLI tool that pulls data from Contentful and turns it into Markdown or YAML files for use with a static site generator. It can be used with any static site generator that uses Markdown with YAML frontmatter, but it has some features that are specific to Hugo.

Prerequisites

Install Node.js

Installation

Usage

Complete configuration then run the following command in the terminal

contentful-hugo

Failure to complete configuration will return an error in the console

Environment Variables not set

Config file not found

Configuration

Environment Variables

Before using you must first set the following environment variables. CONTENTFUL_SPACE, and CONTENTFUL_TOKEN.

This can be done with a .env file in the root directory of your project.

CONTENTFUL_SPACE = '<your-space-id>`
CONTENTFUL_TOKEN = '<content-api-access-token>`

You can also declare the environment variables in the command line

Config File

In order to pull the data you want you will need to create a contentful-settings.yaml file in the root of your repository.

# Single instance types. 
# For these content types contentful-hugo will only pull the most recent entry of a content type. Useful for things like homepages and settings
singleInstances: 
  - id: homepage # content type id (required)
    directory: /content/ # destination directory (required)
    fileName: _index # filename (required)
    fileExtension: md # can be "md", "yaml", or "yml". It defaults to "md" 

  - id: siteSettings
    directory: /data/ # example of a single instance being used for a data file instead of a content file
    fileName: settings
    fileExtension: yaml

# repeated content types
contentTypes:
  - id: posts # content type ID (required)
    directory: /content/posts/ # destination directory (required)
    fileExtension: # This can be "md", "yaml", or "yml". It defaults to "md" if not set.
    mainContent: content # field you want to map as main content (optional. Does not work with rich-text fields. See below)
    isHeadless: false # makes content type a headless bundle (see hugo docs)
  
  - id: seoFields
    isHeadless: true 
    directory: /content/seo-fields/

  - id: reviews
    directory: /content/reviews/
    mainContent: reviewBody

  - id: staff
    isHeadless: true
    directory: /content/staff/

FAQs

Package last updated on 08 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc