Strapi plugin logo for Export To Hugo

Export To Hugo

Export hugo file using strapi v5

Export To Hugo

Provide Strapi v5 to generate your hugo. This plugin is open to everyone and everyone can contribute and modify it. The future of Export To Hugo is decided by each of you.

Features

  • Automatically generate Strapi Content-Type suitable for Hugo, avoiding manual creation and saving time.
  • Export the data of Strapi v5 into the files required by hugo to facilitate hugo operation.
  • Automatically git commit and push to Github

Version

Strapi version: V5 (The following tutorial is based on 5.13.1)

Hugo version: Not Sure. (The following tutorial is based on hugo_extended_0.147.4)

Directory

You need to create a project directory.

There are two folders under the project root directory, one is hugo and the other is strapi. You can't change their names.

Install

1git init

Hugo

In the following examples, I use the hugo_extended_0.147.4 as a demonstration.

1.\hugo.exe new site hugo

If you have your own template, you can install it via git submodule.

Or you can install your template via any method supported by hugo.

1git submodule add https://YOUR_THEME_URL.git hugo/themes/YOUR_THEME_DIRECTORY

Strapi

Run the following command in a terminal:

1npx create-strapi@latest strapi

Here is an example, You can set them according to your needs.

1? Please log in or sign up. (Use arrow keys)
2> Login/Sign up
3? Please log in or sign up. Skip
4? Do you want to use the default database (sqlite) ? (Y/n)
5? Do you want to use the default database (sqlite) ? Yes
6? Start with an example structure & data? (y/N)
7? Start with an example structure & data? No
8? Start with Typescript? (Y/n) n
9? Start with Typescript? No
10? Install dependencies with npm? (Y/n)
11? Install dependencies with npm? Yes
12? Initialize a git repository? (Y/n) n
13? Initialize a git repository? No

Export To Hugo

Run the following command in a terminal:

1cd .\strapi\
2npm i strapi-export-to-hugo

Start Strapi

1yarn develop

How To Use

Generating Content-Type

After logging into Strapi, on the left side of the menu bar, select export-to-hugo.

Select Content-Type Generator.

After Clicking, you will be prompted that the creation is successful. Then return to Content Manager to see the automatically generated Content-Type.

Then you can complete all your Hugo content, just in Strapi.

Generate Gugo Files

On the left side of the menu bar, select Hugo File Generator.

Click the second button to update the hugo file.

Sync to Github

You need to add something to your .env file.

1#Github
2GITHUB_REPO=YOUR_GITHUB_NAME/YOUR_GITHUB_REPO
3GITHUB_BRANCH=YOUR_REPO_BRANCH
4GITHUB_USERNAME=YOUR_GITHUB_NAME
5GITHUB_TOKEN=YOUR_GITHUB_TOKEN

On the left side of the menu bar, select Sync to GitHub (The third button)

Just wait patiently for your Github to update. It will automatically commit and push operations.

Start Hugo

1cd .\hugo\
2.\hugo.exe server --gc

Development

Local Publishing

In export-to-hugo directory

1yarn build
2yalc publish

In strapi directory

1npx yalc add --link strapi-export-to-hugo
2yarn install
3yalc update strapi-export-to-hugo
4yarn develop

Publishing to npm

1npm login
2npm publish

Thanks

This project thanks Cursor for his help.

Install now

npm install strapi-export-to-hugo

STATS

1 GitHub star88 weekly downloads

Last updated

1 day ago

Strapi Version

5.13.0 and above

Author

github profile image for HERFOM
HERFOM

Useful links

Create your own plugin

Check out the available plugin resources that will help you to develop your plugin or provider and get it listed on the marketplace.