Git Product home page Git Product logo

hexo-material-netlify's Introduction

Hexo + Netlify CMS Starter

Intro

This is an example site built with Hexo and Netlify CMS, based on Viosey's Hexo material theme.

Live demo

Deploy to Netlify

Use the following deploy button to get your own copy of the repository up and running:

Deploy to Netlify

The Deploy to Netlify button clones a copy of this repository to your own GitHub or GitLab account. You can clone this repository to your computer for local development.

Local Development

$ git clone --recursive https://github.com/lunaceee/hexo-material-netlify.git
$ cd hexo-material-netlify
$ npm install
$ hexo server

Notice that the --recursive flag is important here, as the material theme is introduced as a submodule.

Alternatively, you can update submodules manually:

cd hexo-material-netlify
git submodule init
git submodule update

Netlify CMS editor workflow

The Netlify CMS admin panel is already set up in the repo. You can access it via yourwebsite.com/admin, e.g. localhost:4000/admin. To understand more about the configuration, check out Netlify CMS docs.

Internationalization with Language-Based Redirects

Netlify supports a wide range of Redirect & Rewrite Rules. Our example site is featuring the Language-based redirecs, which comes in handy for any sites that support multiple languages.

To enable language based redirects, make sure the following configurations in your root _config.yml file is included:

language: 
  - [language_01]
  - [language_02]
  - [language_03]
i18n_dir: :lang

In the markdown file, make sure you specify the language of the post in the front matter:

lang: [language of preference]

Example code of language based redirect rules:

/           /zh-cn          302  Language=zh
/about      /zh-cn/about    302  Language=zh

/           /es             302  Language=es

Now, if your browser language is set to zh-cn, you'll be taken to https://yourwebsite.com/zh-cn/ automatically. You can apply this technique for any other languages. Make sure that the file path in the redirect rules match your folder structures. E.g., I created a zh-cn folder for all the pages in Chinese and added an about folder containing the about page:

source/
├── _data
│   └── head.json
├── _posts
│   ├── Platero
│   │   └── platero.jpg
│   ├── Platero.md
│   ├── hello-world.md
│   └── 你好.md
├── _redirects
├── admin
│   ├── config.yml
│   └── index.html
├── images
│   └── uploads
│       └── netlify-logo.png
└── zh-cn
    ├── about
    │   └── index.md
    └── index.md

Thus, in my _redirects file, I specified /zh-cn/about as a redirect rule for the about page in Chinese.

Display a single language on the home page

By default, our theme shows posts in all languages on the home page. Ideally we only want to show posts written in the default language of the browser. I found a nice plug-in hexo-generator-index-i18n to filter out the unrelated posts. For example, if you go to https://yourwebsite.com/zh-cn/, you'd only see the posts written in Chinese.

hexo-material-netlify's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.