Static Content Generator--wyam

Source: Internet
Author: User

(This article also published in my public number "dotnet daily Essence article", Welcome to the right QR code to pay attention to. )

Preface: Today continue the topic of static Web site, introduce me to choose a use. NET development of the static content generator--wyam.

Technology selection

After deciding to start a static site, the first question is how to generate static content. Do you have a ready tool? Does such a tool meet recent and long-term requirements? If not, what technical ideas do you develop yourself?

With this problem, I quickly Bing to the https://www.staticgen.com/website, which brings together almost all the open source static site generators that exist on the market.

Unsurprisingly, the first is Jekyll, which has a star up to 22822 on GitHub. Jekyll Although the most popular, but it is mainly used for blog site generation, I am currently mainly for Enterprise CMS, more importantly, it is written by Ruby, this is not my most familiar development platform.

But staticgen the language filtering option, in. NET language, there are only Pretzel,wyam,graze,misakai Baker four tools. Although Pretzel uses the same liquid template engine as Jekyll, it may be more adaptable, but after a preliminary study of the 4 tools, Wyam is basically selected. He can basically meet my technical requirements for static content generators:

    • Architecture is designed with extensibility in mind based on familiar language and platform development. This makes it easy for me to expand as needed.
    • Use a familiar and relatively extensive template language and engine. Make it easy for me to create templates (content input) and train other people.
    • It is easy to inject meta data. Because the CMS may need to inject more and more complex data.
    • Can be embedded to run. Many generators are command-line tools, but I might need to have the generator run in the background.
Introduction of Wyam

Waym.io official on-line self-introduction basically put Wyam is what said is very clear, I will simply translate here.

The Wyam is different. It is not a clone of Jekyll (it does not mean that Jekyll has any problems), it is not designed to generate blogs (although it is also well qualified for this task). Waym is a static content generator that can be used to generate Web sites, documents, ebooks, and more. Since everything is strung together through a lot of flexible modules (you can also write your own modules), the only limitation is your imagination.

Among its characteristics, I am particularly interested in:

    • The configuration file is written in C # script, thanks to Roslyn's powerful
    • Simple and straightforward way to use meta data
    • Support for a variety of template engines and languages, especially the direct built-in razor support (and razor support is based on the ASP. NET MVC 6 source, will support Taghelper in the future). Of course there are markdown support or extension of their own template language support.
    • Integrated Web server makes it easy to preview when writing templates
    • Full support for NuGet, which automatically downloads dependent nuget packages during build execution
    • More importantly, it supports embedded running
    • Relatively complete and clear documentation

Waym actually draws on the advantages and design of existing other static content generators, such as Frontmatter support (via YAML). Although it is still only 0.11, the completion of the function is still relatively high, and you can directly pull request to participate in the contribution. Source code address is: Https://github.com/Wyamio/Wyam

Use of Wyam

The use of Wyam is straightforward and executes directly from the command line, as follows:

c:\mysite>Wyam.exe--preview--watchLoading configuration from c:\MySite\config.wyam.Cleaning output Directory C:\MySite\.\Output ... Cleaned output directory. Executing 3 pipelines    ... Executing pipeline "Markdown" (1/3) with 5 child module (s)    ... Executed Pipeline "Markdown" (1/3) resulting in 0 output document (s).    Executing pipeline "Razor" (2/3) with 4 child module (s)    ... Executed Pipeline "Razor" (2/3) resulting in 2 output document (s).    Executing pipeline "Resources" (3/3) with 1 child module (s)    ... Executed Pipeline "Resources" (3/3) resulting in output document (s). Executed 3 pipelines. Preview server running on port 5080...Watching folder C:\MySite\.\Input ... Hit any key to exit ...

Wyam has a examples folder in the source code, there are some examples to refer to. In fact, Wyam.io this site itself is used Wyam to generate, and there are source code, so it is a good reference. Of course I also made a simple example that can be downloaded here: Https://zyg.blob.core.windows.net/test/SampleTemplate.zip.

Static Content Generator--wyam

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.