Is it possible to create print templates in 2.6 and 2.8?

Is this possible? I can only find the option to 'Add items from template'. When using this option, the page setup defaults to A4 landscape and you must manually change these settings using the composition tab within the print composer.

Version 2.4 and earlier did not need this extra step. Applying a pre-saved print composer not only loaded in all the objects previously saved within the template but also replicated the page set-up

Am I missing something really obvious?

You should be able to create one directly from a template using the composer manager.

Project>Composer Manager…

In there you can add a new print composer based on a specific template.

All elements of a project are consolidated into the project package ( .ppkx ), including maps and 3D views, the data and layers in the maps, toolboxes, geoprocessing history items, styles, layouts, and folders or connections (server, workflow, and so on) when appropriate.

Project packages, by default, are created for internal use. The Share outside of organization parameter allows you to control if a package is to be created for either internal (inside your organizations network) or external use. When Share outside of organization is checked, enterprise geodatabase layers and data referenced from a UNC path will be included in the project package.

Data sources must be referenced from either an enterprise geodatabase or UNC file path to create an internal package where the data remains referenced. Local data paths will always be consolidated and packaged. Creating an internal package where data is only referenced will open with broken links if shared outside your environment or to colleagues who do not have access to either the enterprise geodatabase or the UNC data shares.

Templates can be created using the Package as template parameter. A project template ( .aptx file) can help you create a new project by defining layers, maps, and data as well as required connections.

Toolboxes that are part of a project are analyzed using the Analyze Tools for Pro tool before the consolidation process is performed. Identified errors will stop the consolidation process. You will need to either fix those errors or remove the tool from the project. Input data used by the tool will be consolidated, regardless of whether the data is part of a map in the project. Toolboxes can be excluded from the output project package by unchecking the Include Toolboxes parameter.

Similar to project toolboxes, geoprocessing history (the result information from executing a geoprocessing tool) will be included in the package. Data required to execute the history item will be included in the output package regardless of whether it exists in a map or scene. Any history items that are invalid (failed during execution) or where data cannot be found will cause the packaging process to halt. You will need to remove or fix the history item in question. History items can be excluded from a project package by unchecking the Include History Items parameter.

Connections—such as folder, server, database and workflow—will only be included in an internal package. These items are removed if the package is created to be shared outside your organization.

Items such as attachments, styles, and tasks will be referenced for internal packages if they were part of the project from a UNC path. These items will be copied and packaged in all other situations.

For feature layers, the Extent parameter is used to select the features that will be consolidated. For raster layers, the Extent parameter is used to clip the raster datasets.

Files that document maps and data or provide additional information can be included in the package. Images, PDFs, word documents, and .zip files can be included in the package by referencing them with the Additional Files parameter.


Project packages ( .ppkx files) can only be created and opened with ArcGIS Pro .

Frequently Asked Questions:

Yes! We're the same great company delivering top-quality event ticket printing and low prices with the best customer service around! We've undergone a rebrand so that we can offer our customers even more services, such as our online fundraising and events platforms as well as custom printed merchandise!

Lightning fast! If you order custom-printed event tickets before 3 p.m. CST, they will ship out from our facility the next business day—that's a 24-hour turnaround! Place your order Monday before 3 p.m. CST, and it will ship out Tuesday. Remember, weekends don't count, so if you place your order Saturday, it will be processed Monday and ship out Tuesday. For quantities over 5000 and stapled-ticket orders, the processing time will be longer. Click here for more details about Quick Ticket Processing Times.

Once your printed event tickets leave our facility, it's all up to UPS. You can choose the shipping option that best fits your schedule and budget—you'll find a listing of UPS shipping methods on our Quick Ticket Processing Times page. You can also check out the shipping time map for UPS Ground.

Yes! Your satisfaction is our #1 priority, period. We take great care to ensure we provide the highest quality products at affordable prices with a fast turnaround. If you are not completely satisfied with your order, please contact our customer support specialists at 888.771.0809 or at [email protected] We will issue a full refund for the product's price minus the shipping fees or re-do your order - the choice is yours. Read more about our satisfaction guarantee.

The actual design is free, but the exact price of your order will vary. Things like color or black ink, the number of image uploads, your choice of stapling, the type of paper you select, and, of course, the number of tickets or other products you order all affect the price.

For the least expensive tickets, choose a black-and-white design with no images!

Most of our event tickets come equipped with stubs. If you'd like a selection of stubless tickets, please browse our coupon, and drink ticket templates – those designs can double as stubless event tickets. Some Eventgroove customers have even used invitations as event tickets!

Yes! Ordering items together will save you shipping costs but delay the delivery of your tickets since our custom products have a longer turnaround.

Since the ordering process is different for online and custom products, please do not complete your online order. Instead, simply create an account online and add the tickets to your cart. After entering your shipping and billing information online, please call our customer support team at 888.771.0809. They will start the custom product ordering process and finalize your order once all the necessary information is received.

That's because the proof reflects only the printing, not the background or the paper color. Once printed, anything that appears white in your proof will be the color of your selected paper.

You can! Our digital proofs offer a good facsimile of your physical ticket. However, if you're worried about the quality of our online templates or an image you uploaded, you can call our customer support team at 888.771.0809 and request a physical sample. We'll put your order on hold and send you one unperforated sample sheet via UPS Next Day Air at no cost (free!).

Since we never start printing until a proof is approved, please keep in mind that requesting a physical proof will delay your order. Also, if you call after UPS has picked up its Next Day Air shipments for the day, we will not be able to ship the sample sheet the same day.

Once you receive your physical proof, please call customer support to either confirm your order or cancel it at no cost. If you are not satisfied with the proof, we will refund your money and you can make the necessary changes to your online template before resubmitting the order.

We hope you will! We love to share. If you'd like to check the quality of our products, we're always happy to send you a sample package at no cost. You can request several samples on our free sample page.

We have several event ticket paper stocks from which to choose! Our most popular is our signature 100lb cover stock. It's bright white with an uncoated, ultra-smooth finish. You can also choose from 100% Recycled Durable 111lb cover stock, heavyweight stock, heavyweight 100lb (11pt) heat-sensitive security media, souvenir-quality heavyweight coated semi-gloss, and heavyweight 100lb (11pt) UV security media. Prices for our card stocks vary, so as you review each kind before checkout, keep an eye on the pricing summary on the right hand of your screen!

We'd like to think they're both great! The smooth finish has a matte appearance while the semi-gloss finish has more shine, so colors tend to stand out more with the semi-gloss finish. Other than that, both papers are a top-quality, heavyweight ticket stock that makes your tickets look professional and feel great in hand. They have about the same weight as an expensive business or greeting card.

No matter the design, card stock, or the size they measure on your device or computer screen, your printed tickets measure 5.63 x 1.97 inches. Don't worry about remembering ticket dimensions—they're written in the ticket template description and are displayed in the ordering summary before you check out!

That depends on the design you've chosen! Each event ticket template features a unique motif and layout, making the number of characters per line different for each template. To see if your test fits in the event ticket template you've selected, simply enter all your information into the ticket template and then click "View Proof" at the bottom of the page. If your text doesn't fit, the lines with too many characters will appear in red within your proof. From there, you can make revisions to ensure your text fits within the event ticket template's parameters. Keep in mind that capital letters need more space than lowercase letters, and vertical layouts usually allow for less text than horizontal layouts.

Yes! Many of our ticket templates have space to upload your own image. To find them, type "image" into our search box, and our vast selection of event ticket templates with image upload spots will appear. Please remember that the design of our event ticket templates cannot be altered—you can only add text or images to the available fields.

Can't quite find the event ticket template that suits you? We can create a custom design! Just email us at [email protected] with the details and we'll provide you with a fast quote.

Yes! Simply leave any lines blank within the online template, and that space will remain blank on your finished print product. However, since our templates are standardized and the process is automated, there is no way to add a text line or reposition the text without paying for a custom ticket order. Visit our Custom Order Request page for more information.

Nothing! If you choose not to upload an image, the online template background will appear where you see the image placeholder.

Why conduct a concerns survey?

Conducting a concerns survey will inform your efforts to be sure people's pressing concerns are addressed. Additional reasons to consider conducting a concerns survey:

  • It involves community members in the decision-making process early on, which increases their likelihood of getting actively involved and staying involved. Helping community members start thinking about health and community development problems motivates them to get involved. These are their issues!
  • It asks community members to define what they see as most important. This is the kind of information that you won't get from outside professionals.
  • It can be a reliable, systematic, and easy to use way to tap into information.
  • It helps coalition members and citizens realize how they view their community.
  • It provides a useful source of information and direction for initiatives, funders, and participants.
  • It keeps your organization's agenda from only reflecting the interests of service providers. Getting the perspective of the people your group serves is important.
  • It helps set the agenda for community work.
  • It builds consensus.

2 Introduction

SWIG is a software development tool that simplifies the task of interfacing different languages to C and C++ programs. In a nutshell, SWIG is a compiler that takes C declarations and creates the wrappers needed to access those declarations from other languages including including Perl, Python, Tcl, Ruby, Guile, and Java. SWIG normally requires no modifications to existing code and can often be used to build a usable interface in only a few minutes. Possible applications of SWIG include:

  • Building interpreted interfaces to existing C programs.
  • Rapid prototyping and application development.
  • Interactive debugging.
  • Reengineering or refactoring of legacy software into a scripting language components.
  • Making a graphical user interface (using Tk for example).
  • Testing of C libraries and programs (using scripts).
  • Building high performance C modules for scripting languages.
  • Making C programming more enjoyable (or tolerable depending on your point of view).
  • Impressing your friends.
  • Obtaining vast sums of research funding (although obviously not applicable to the author).

SWIG was originally designed to make it extremely easy for scientists and engineers to build extensible scientific software without having to get a degree in software engineering. Because of this, the use of SWIG tends to be somewhat informal and ad-hoc (e.g., SWIG does not require users to provide formal interface specifications as you would find in a dedicated IDL compiler). Although this style of development isn't appropriate for every project, it is particularly well suited to software development in the small especially the research and development work that is commonly found in scientific and engineering projects.

2.2 Why use SWIG?

As stated in the previous section, the primary purpose of SWIG is to simplify the task of integrating C/C++ with other programming languages. However, why would anyone want to do that? To answer that question, it is useful to list a few strengths of C/C++ programming:

  • Excellent support for writing programming libraries.
  • High performance (number crunching, data processing, graphics, etc.).
  • Systems programming and systems integration.
  • Large user community and software base.

Next, let's list a few problems with C/C++ programming

  • Writing a user interface is rather painful (i.e., consider programming with MFC, X11, GTK, or any number of other libraries).
  • Testing is time consuming (the compile/debug cycle).
  • Not easy to reconfigure or customize without recompilation.
  • Modularization can be tricky.
  • Security concerns (buffer overflow for instance).

To address these limitations, many programmers have arrived at the conclusion that it is much easier to use different programming languages for different tasks. For instance, writing a graphical user interface may be significantly easier in a scripting language like Python or Tcl (consider the reasons why millions of programmers have used languages like Visual Basic if you need more proof). An interactive interpreter might also serve as a useful debugging and testing tool. Other languages like Java might greatly simplify the task of writing distributed computing software. The key point is that different programming languages offer different strengths and weaknesses. Moreover, it is extremely unlikely that any programming is ever going to be perfect. Therefore, by combining languages together, you can utilize the best features of each language and greatly simplify certain aspects of software development.

  • A collection of functions and variables that do something useful.
  • A main() program that starts everything.
  • A horrible collection of hacks that form some kind of user interface (but which no-one really wants to touch).

Instead of going down that route, incorporating C/C++ into a higher level language often results in a more modular design, less code, better flexibility, and increased programmer productivity.

SWIG tries to make the problem of C/C++ integration as painless as possible. This allows you to focus on the underlying C program and using the high-level language interface, but not the tedious and complex chore of making the two languages talk to each other. At the same time, SWIG recognizes that all applications are different. Therefore, it provides a wide variety of customization features that let you change almost every aspect of the language bindings. This is the main reason why SWIG has such a large user manual -).

2.3 A SWIG example

The best way to illustrate SWIG is with a simple example. Consider the following C code:

Suppose that you wanted to access these functions and the global variable My_variable from Tcl. You start by making a SWIG interface file as shown below (by convention, these files carry a .i suffix) :

2.3.1 SWIG interface file

The interface file contains ANSI C function prototypes and variable declarations. The %module directive defines the name of the module that will be created by SWIG. The % block provides a location for inserting additional code such as C header files or additional C declarations.

2.3.2 The swig command

SWIG is invoked using the swig command. We can use this to build a Tcl module (under Linux) as follows :

The swig command produced a new file called example_wrap.c that should be compiled along with the example.c file. Most operating systems and scripting languages now support dynamic loading of modules. In our example, our Tcl module has been compiled into a shared library that can be loaded into Tcl. When loaded, Tcl can now access the functions and variables declared in the SWIG interface. A look at the file example_wrap.c reveals a hideous mess. However, you almost never need to worry about it.

2.3.3 Building a Perl5 module

Now, let's turn these functions into a Perl5 module. Without making any changes type the following (shown for Solaris):

2.3.4 Building a Python module

Finally, let's build a module for Python (shown for Irix).

2.3.5 Shortcuts

To the truly lazy programmer, one may wonder why we needed the extra interface file at all. As it turns out, you can often do without it. For example, you could also build a Perl5 module by just running SWIG on the C header file and specifying a module name as follows

2.4 Supported C/C++ language features

A primary goal of the SWIG project is to make the language binding process extremely easy. Although a few simple examples have been shown, SWIG is quite capable in supporting most of C++. Some of the major features include:

  • Full C99 preprocessing.
  • All ANSI C and C++ datatypes.
  • Functions, variables, and constants.
  • Classes.
  • Single and multiple inheritance.
  • Overloaded functions and methods.
  • Overloaded operators.
  • C++ templates (including member templates, specialization, and partial specialization).
  • Namespaces.
  • Variable length arguments.
  • C++ smart pointers.

Currently, the only major C++ feature not supported is nested classes--a limitation that will be removed in a future release.

It is important to stress that SWIG is not a simplistic C++ lexing tool like several apparently similar wrapper generation tools. SWIG not only parses C++, it implements the full C++ type system and it is able to understand C++ semantics. SWIG generates its wrappers with full knowledge of this information. As a result, you will find SWIG to be just as capable of dealing with nasty corner cases as it is in wrapping simple C++ code. In fact, SWIG is able handle C++ code that stresses the very limits of many C++ compilers.

2.5 Non-intrusive interface building

When used as intended, SWIG requires minimal (if any) modification to existing C or C++ code. This makes SWIG extremely easy to use with existing packages and promotes software reuse and modularity. By making the C/C++ code independent of the high level interface, you can change the interface and reuse the code in other applications. It is also possible to support different types of interfaces depending on the application.

2.6 Incorporating SWIG into a build system

SWIG is a command line tool and as such can be incorporated into any build system that supports invoking external tools/compilers. SWIG is most commonly invoked from within a Makefile, but is also known to be invoked from from popular IDEs such as Microsoft Visual Studio.

If you are using the GNU Autotools (Autoconf/ Automake/ Libtool) to configure SWIG use in your project, the SWIG Autoconf macros can be used. The primary macro is ac_pkg_swig, see The ac_python_devel macro is also helpful for generating Python extensions. See the Autoconf Macro Archive for further information on this and other Autoconf macros.

There is growing support for SWIG in some build tools, for example CMake is a cross-platform, open-source build manager with built in support for SWIG. CMake can detect the SWIG executable and many of the target language libraries for linking against. CMake knows how to build shared libraries and loadable modules on many different operating systems. This allows easy cross platform SWIG development. It also can generate the custom commands necessary for driving SWIG from IDE's and makefiles. All of this can be done from a single cross platform input file. The following example is a CMake input file for creating a python wrapper for the SWIG interface file, example.i:

The above example will generate native build files such as makefiles, nmake files and Visual Studio projects which will invoke SWIG and compile the generated C++ files into (UNIX) or _example.pyd (Windows). For other target languages on Windows a dll, instead of a .pyd file, is usually generated.

2.7 Hands off code generation

SWIG is designed to produce working code that needs no hand-modification (in fact, if you look at the output, you probably won't want to modify it). You should think of your target language interface being defined entirely by the input to SWIG, not the resulting output file. While this approach may limit flexibility for hard-core hackers, it allows others to forget about the low-level implementation details.

2.8 SWIG and freedom

No, this isn't a special section on the sorry state of world politics. However, it may be useful to know that SWIG was written with a certain "philosophy" about programming---namely that programmers are smart and that tools should just stay out of their way. Because of that, you will find that SWIG is extremely permissive in what it lets you get away with. In fact, you can use SWIG to go well beyond "shooting yourself in the foot" if dangerous programming is your goal. On the other hand, this kind of freedom may be exactly what is needed to work with complicated and unusual C/C++ applications.

Ironically, the freedom that SWIG provides is countered by an extremely conservative approach to code generation. At it's core, SWIG tries to distill even the most advanced C++ code down to a small well-defined set of interface building techniques based on ANSI C programming. Because of this, you will find that SWIG interfaces can be easily compiled by virtually every C/C++ compiler and that they can be used on any platform. Again, this is an important part of staying out of the programmer's way----the last thing any developer wants to do is to spend their time debugging the output of a tool that relies on non-portable or unreliable programming features.

2.6 Setting Up Next Numbers for Legal Documents

This section provides an overview of next numbers for legal documents and discusses how to set up next numbers.

2.6.1 Understanding Next Numbers for Legal Documents

The numbering for each type of legal document must be consecutive. Because you can print some of the legal documents from more than one JD Edwards EnterpriseOne program, you set up next numbers for legal documents so that the system assigns a valid next number no matter which program you use to print a document.

You use the Legal Document Next Number program (P7400001) to set up different next numbering schemes for each type of legal document. For example, you might set up a next numbering scheme for standard invoices and a different next numbering scheme for VAT invoices.

The system stores the next numbering schemes in the Legal Document Next Numbers table (F7400001).

2.6.2 Forms Used to Set Up Next Numbers for Legal Documents

Form Name FormID Navigation Usage
Work with Next Legal Document Numbers W7400001A Legal Document Set Up (G74LDOC), Legal Document Next Number Review or select an existing numbering scheme.
Next Legal Document Numbers Revision W7400001B On the Work with Next Legal Document Numbers form, click Add. Set up next numbers for legal documents.

2.6.3 Setting Up Next Numbers for Legal Documents

Access the Next Legal Document Numbers Revision form.

Figure 2-4 Next Legal Document Numbers Revision form

Enter the company for which you set up the next numbers.

Enter the legal document type for which you set up next numbers. The value that you enter must exist in the F7400002 table.

Enter the code that represents the place of issue for the legal document. The value that you enter must exist in the F7400004 table.

Legal Document Type Same As

Enter the legal document type that shares the same next numbering scheme. The value that you enter must exist in the F7400002 table.

Enter the number that precedes the number that the system uses as the first number in the next numbering scheme. For example, if you enter 99, the system uses 100 as the first number in the next numbering scheme for the legal document type that you specify.

2.5 Templates

A Hugo theme consists of two major components: templates, and web assets. The former is essential, and tells Hugo how to render a page. 22 The latter is optional but also important. It typically consists of CSS and JavaScript files, as well as other assets like images and videos. These assets determine the appearance and functionality of your website, and some may be embedded in the content of your web pages.

You can learn more about Hugo templates from the official documentation ( There are a great many different types of templates. To make it easier for you to master the key ideas, I created a very minimal Hugo theme, which covers most functionalities that an average user may need, but the total number of lines is only about 150, so we can talk about all the source code of this theme in the following subsection.

2.5.1 A minimal example

XMin is a Hugo theme I wrote from scratch in about 12 hours. Roughly half an hour was spent on templates, 3.5 hours were spent on tweaking the CSS styles, and 8 hours were spent on the documentation ( I think this may be a representative case of how much time you would spend on each part when designing a theme. It is perhaps our nature to spend much more time on cosmetic stuff like CSS than essential stuff like templates. Meanwhile, coding is often easier than documentation.

We will show the source code of the XMin theme. Because the theme may be updated occasionally in the future, you may follow this link to obtain a fixed version that we will talk about in this section: Below is a tree view of all files and directories in the theme: and are not required components of a theme, but you definitely should choose a license for your source code so that other people can properly use your code, and a README can be the brief documentation of your software.

The file archetypes/ defines the default template based on which users can create new posts. In this theme, only provided empty YAML metadata:

The most important directories of a theme are layouts/ and static/ . HTML templates are stored under layouts/ , and assets are stored under static/ .

To understand layouts/ , you must know some basics about HTML (see Section B.1) because the templates under this directory are mostly HTML documents or fragments. There are many possible types of subdirectories under layouts/ , but we are only going to introduce two here: _default/ and partials/ .

The _default/ directory is where you put the default templates for your web pages. In the XMin theme, we have three templates: single.html , list.html , and terms.html .

single.html is a template for rendering single pages. A single page basically corresponds to a Markdown document under content/ , and it contains both the (YAML) metadata and content. Typically we want to render the page title, author, date, and the content. Below is the source code of XMin’s single.html :

You see a lot of pairs of double curly braces <<>> , and that is how you program the templates using Hugo’s variables and functions.

The template starts with a partial template header.html , for which you will see the source code soon. For now, you can imagine it as all the HTML tags before the body of your page (e.g., <html><head> ). Partial templates are mainly for reusing HTML code. For example, all HTML pages may share very similar <head></head> tags, and you can factor out the common parts into partial templates.

The metadata of a page is included in a <div> element with the class article-meta . We recommend that you assign classes to HTML elements when designing templates, so that it will be easier to apply CSS styles to these elements using class names. In a template, you have access to many variables provided by Hugo, e.g., the .Title variable stores the value of the page title, and we write the title in a <span> in a first-level header <h1> . Similarly, the author and date are written in <h2> , but only if they are provided in the YAML metadata. The syntax << with FOO >><< . >><< end >> is a shorthand of <><< FOO >><< end >> , i.e., it saves you the effort of typing the expression FOO twice by using << . >> . The method .Format can be applied to a date object, and in this theme, we format dates in the form YYYY/mm/dd ( 2006/01/02 is the way to specify the format in Go).

Then we show the content of a page, which is stored in the variable .Content . The content is wrapped in a semantic HTML tag <main> .

The template is finished after we include another partial template footer.html (source code to be shown shortly).

To make it easier to understand how a template works, we show a minimal example post below:

Using the template single.html , it will be converted to an HTML page with source code that looks more or less like this (with the header and footer omitted):

For a full example of a single page, you may see

list.html is the template for rendering lists of pages, such as a list of blog posts, or a list of pages within a category or tag. Here is its source code:

Again, it uses two partial templates header.html and footer.html . The expression <> means, if this list is not the home page, show the page title. This is because I do not want to display the title on the homepage. It is just my personal preference. You can certainly display the title in <h1> on the home page if you want.

The << .Content >> shows the content of the list. Please note that typically .Content is empty, which may be surprising. This is because a list page is not generated from a source Markdown file by default. However, there is an exception. When you write a special Markdown file under a directory corresponding to the list name, the .Content of the list will be the content of this Markdown file. For example, you can define the content of your homepage in content/ , and the content of the post list page under content/post/ .

Next we generate the list using a loop ( range ) through all pages filtered by the condition that the section of a page should not be empty. “Section” in Hugo means the first-level subdirectory name under content/ . For example, the section of content/post/ is post . Therefore the filter means that we will list all pages under subdirectories of content/ . This will exclude pages under the root content/ directory, such as content/ .

Please note that the variable .Data is dynamic, and its value changes according to the specific list you want to generate. For example, the list page only contains pages under content/post/ , and only contains pages under content/note/ . These list pages are automatically generated by Hugo, and you do not need to explicitly loop through the sections post and note . That is, a single template list.html will generate multiple lists of pages according to the sections and taxonomy terms (e.g., categories and tags) you have on your website.

The list items are represented by the HTML tags <li> in <ul> . Each item consists of the date, link, and title of a page. You may see for a full example of a list page.

terms.html is the template for the home page of taxonomy terms. For example, you can use it to generate the full list of categories or tags. The source code is below:

Similar to list.html , it also uses a loop. The variable .Data.Terms stores all terms under a taxonomy, e.g., all category names. You can think of it as a named list in R (called a map in Go), with the names being the terms and the values being lists of pages. The variable $key denotes the term and $value denotes the list of pages associated with this term. What we render in each <li> is a link to the term page as well as the count of posts that used this term ( len is a Go function that returns the length of an object).

Hugo automatically renders all taxonomy pages, and the path names are the plural forms of the taxonomies, e.g., and That is the meaning of .Data.Plural . The leading $ is required because we are inside a loop, and need to access variables from the outside scope. The link of the term is passed to the Hugo function relURL via a pipe | to make it relative, which is good practice because relative links are more portable (independent of the domain name).

The partials/ directory is the place to put the HTML fragments to be reused by other templates via the partial function. We have four partial templates under this directory:

header.html main defines the <head> tag and the navigation menu in the <nav> tag.

The <head> area should be easy to understand if you are familiar with HTML. Note that we also included a partial template head_custom.html , which is empty in this theme, but it will make it much easier for users to add customized code to <head> without rewriting the whole template. See Section 2.6 for more details.

The navigation menu is essentially a list, and each item of the list is read from the variable .Site.Menus.main . This means users can define the menu in config.toml , e.g.,

It will generate a menu like this:

Hugo has a powerful menu system, and we only used the simplest type of menu in this theme. If you are interested in more features like nested menus, please see the full documentation at

footer.html defines the footer area of a page and closes the HTML document:

The purpose of the partial template foot_custom.html is the same as head_custom.html that is, to allow the user to add customized code to the <footer> without rewriting the whole template.

Lastly, we use the variable .Site.Params.footer to generate a page footer. Note we used the with function again. Recall that the syntax << with .Site.Params.footer >><< . >><< end >> is a shorthand for <><< .Site.Params.footer >><< end >> . This syntax saves you from typing the expression .Site.Params.footer twice by using << . >> as a placeholder for the variable footer , which is defined as a site parameter in our config.toml file. The additional function markdownify can convert Markdown to HTML (i.e., << . | markdownify >> . Altogether, this sequence means we can define a footer option using Markdown under params in config.toml , e.g.,

There is a special template 404.html , which Hugo uses to create the 404 page (when a page is not found, this page is displayed):

With all templates above, we will be able to generate a website from Markdown source files. You are unlikely to be satisfied with the website, however, because the HTML elements are not styled at all, and the default appearance may not look appealing to most people. You may have noticed that in header.html , we have included two CSS files, /css/style.css and /css/fonts.css .

You can find many existing open-source CSS frameworks online that may be applied to a Hugo theme. For example, the most popular CSS framework may be Bootstrap: When I was designing XMin, I wondered how far I could go without using any of these existing frameworks, because they are usually very big. For example, bootstrap.css has nearly 10000 lines of code when not minimized. It turned out that I was able to get a satisfactory appearance with about 50 lines of CSS, which I will explain in detail below:

style.css defines all styles except the typefaces:

The maximum width of the page body is set to 800 pixels because an excessively wide page is difficult to read ( 800 is an arbitrary threshold that I picked). The body is centered using the CSS trick margin: auto , which means the top, right, bottom, and left margins are automatic. When a block element’s left and right margins are auto , it will be centered.

Remember that our menu element is a list <ul > defined in header.html . I changed the default display style of <li> within the menu to inline-block , so that they will be laid out from left to right as inline elements, instead of being stacked vertically as a bullet list (the default behavior).

For links ( <a> ) in the menu and the metadata area of an article, the default text decoration (underlines) is removed, and a light background color is applied. The border radius is set to 5 pixels so that you can see a subtle round-corner rectangle behind each link.

The horizontal rule ( <hr> ) is set to a dashed light-gray line to make it less prominent on a page. These rules are used to separate the article body from the header and footer areas.

For code blocks ( <pre> ), I apply light gray borders with drop-shadow effects. Every inline code element has a very light gray background. These decorations are merely out of my own peculiar interest and emphasis in code.

Embedded elements like images and videos that exceed the page margin are often ugly, so I restrict their maximum width to 100%. Hyphenation is turned on for words in <main> . Blockquotes have a gray left sidebar and a light gray background. Tables are centered by default, with only three horizontal rules: the top and bottom borders of the table, and the bottom border of the table head. Table rows are striped to make it easier to read the table especially when the table is wide.

fonts.css is a separate style sheet because it plays a critical role in the appearance of a website, and it is very likely that you will want to customize this file. In most cases, your readers will spend the most time on reading the text on your pages, so it is important to make the text comfortable to read. I’m not an expert in web design, and I just picked Palatino for the body and Lucida Console or Monaco (whichever is available in your system) for the code. It is common to use Google web fonts nowadays. You may try some web fonts and see if you like any of them.

The two CSS files are placed under the static/css/ directory of the theme. In the HTML template header.html , the path /css/style.css refers to the file static/css/style.css .

Lastly, this theme provided an example site under exampleSite/ . The directory structure may be a little confusing because this is a theme instead of a website. In practice, everything under exampleSite/ should be under the root directory of a website, and the top-level hugo-xmin/ directory should be under the themes/ directory of this website, i.e.,

The example site provides a sample config.toml , a home page , an about page , two posts under note/ and two under post/ . It also overrides the foot_custom.html in the theme.

2.5.2 Implementing more features

The XMin is actually a highly functional theme, but we understand that it may be too minimal for you. There are a few commonly used features (intentionally) missing in this theme, and we will teach you how to add them by yourself if desired. All these features and the source code can be applied to other themes, too.

Enable Google Analytics. Hugo has provided a built-in partial template. For XMin, you can add

to layouts/partials/foot_custom.html under the root directory of your website (instead of themes/hugo-xmin/ ), and configure googleAnalytics in the config.toml . See for details, and the HTML source of this page for the JavaScript rendered from the template:

Enable Disqus comments. Similar to Google Analytics, you can add the built-in template

to foot_custom.html , and configure the Disqus shortname in config.toml . See for details, and a preview at

Enable syntax highlighting via highlight.js. Add this to head_custom.html

and this to foot_custom.html :

Remember to replace YOUR-CDN-LINK with the link to your preferred CDN host of highlight.js, e.g., . For more information about highlight.js, please see its homepage: If you need to use other CDN hosts, is a good choice: You can also see which languages and CSS themes are supported there.

Support math expressions through MathJax. Add the code below to foot_custom.html .

This requires substantial knowledge of JavaScript and familiarity with MathJax to fully understand the code above, and we will leave the explanation of the code to Section B.3.

Remember to replace YOUR-CDN-LINK with the link to your preferred CDN host of MathJax, e.g., .

Show the table of contents (TOC). To show a TOC for R Markdown posts, you only need to add the output format blogdown::html_page with the option toc: true to YAML:

For plain Markdown posts, you have to modify the template single.html . The TOC of a post is stored in the Hugo template variable .TableOfContents . You may want an option to control whether to show the TOC, e.g., you may add an option toc: true to the YAML metadata of a Markdown post to show the TOC. The code below can be added before the content of a post in single.html :

Display categories and tags in a post if provided in its YAML. Add the code below where you want to place the categories and tags in single.html , e.g., in <div ></div> .

Basically the code loops through the YAML metadata fields categories and tags , and for each field, its value is obtained from .Param , then we use an inside loop to write out the terms with links of the form <a href="/tags/foo/">foo</a> .

Add pagination. When you have a large number of posts on a website, you may not want to display the full list on a single page, but show N posts (e.g., N = 10) per page. It is easy to add pagination to a website using Hugo’s built-in functions and templates. Instead of looping through all posts in a list template (e.g., range .Data.Pages ), you paginate the full list of posts using the function .Paginate (e.g., range (.Paginate .Data.Pages) ). Below is a template fragment that you may insert to your template file list.html :

Add a GitHub Edit button or link to a page. If none of the above features look exciting to you (which would not surprise me), this little feature is really a great example of showing you the power of plain-text files and static websites, when combined with GitHub (or other services that support the online editing of plain-text files). I believe it would be difficult, if not impossible, to implement this feature in dynamic website frameworks like WordPress.

Basically, when you browse any text files in a repository on GitHub, you can edit them right on the page by hitting the Edit button (see Figure 2.3 for an example) if you have a GitHub account. If you have write access to the repository, you can commit the changes directly online, otherwise GitHub will fork the repository for you automatically, so that you can edit the file in your own repository, and GitHub will guide you to create a pull request to the original repository. When the original owner sees the pull request, he/she can see the changes you made and decide whether to accept them or not or ask you to make further changes. Although the terminology “pull request” is highly confusing to beginners, 23 it is probably the single greatest feature invented by GitHub, because it makes it so much easier for people to make contributions.

What is really handy is that all you need is a URL of a fixed form to edit a file on GitHub: . For example,, where USER is rbind , REPO is yihui , BRANCH is master , and the file path is content/knitr/ .

The key to implementing this feature is the variable .File.Path , which gives us the source file path of a page under content/ , e.g., post/ . If your website only uses plain Markdown files, the implementation will be very simple. I omitted the full GitHub URL in . below, of which an example could be .

However, the case is a little more complicated for blogdown users, when R Markdown posts are involved. You cannot just use .File.Path because it actually points to the .html output file from an .Rmd file, whereas the .Rmd file is the actual source file. The Edit button or link should not point to the .html file. Below is the complete implementation that you may add to a template file depending on where you want to show the Edit link (e.g., footer.html ):

The basic logic is that for a file, if the same filename with the extension .Rmd exists, we will point the Edit link to the Rmd file. First, we define a variable $Rmd to be the filename with the .Rmd extension. Then we check if it exists. Unfortunately, there is no function in Hugo like file.exists() in R, so we have to use a hack: list all files under the directory and see if the Rmd file is in the list. $.Scratch is the way to dynamically store and obtain variables in Hugo templates. Most variables in Hugo are read-only, and you have to use $.Scratch when you want to modify a variable. We set a variable FilePath in $.Scratch , whose value is the full path to the Rmd file when the Rmd file exists, and the path to the Markdown source file otherwise. Finally, we concatenate a custom option GithubEdit in config.toml with the file path to complete the Edit link <a> . Here is an example of the option in config.toml :

Please note that if you use Hugo on Windows to build and deploy your site, you may have to change the file path separators from backslashes to forward slashes, e.g., you may need << $.Scratch.Set "FilePath" (replace ($.Scratch.Get "FilePath") "" "/") >> in the template. To avoid this complication, we do not recommend that you deploy your site through Windows (see Chapter 3 for deployment methods).

You may see for an actual implementation with R Markdown examples, and see the footer of this page for the Edit link: You can actually see a link in the footer of every page, except the lists of pages (because they do not have source files).

FIGURE 2.3: Edit a text file online on GitHub.

After you digest the XMin theme and the implementations of additional features, it should be much easier to understand other people’s templates. There are a large number of Hugo themes but the primary differences among them are often in styles. The basic components of templates are often similar.

The most common functionality of templates is to render HTML pages, but there can also be special templates, for example, for RSS feeds and sitemaps, which are XML files.↩︎

The Context¶

The template context holds the variables of a template. It stores the values passed to the template and also the names the template exports. Creating instances is neither supported nor useful as it’s created automatically at various stages of the template evaluation and should not be created by hand.

The context is immutable. Modifications on parent must not happen and modifications on vars are allowed from generated template code only. Template filters and global functions marked as contextfunction() s get the active context passed as first argument and are allowed to access the context read-only.

The template context supports read only dict operations ( get , keys , values , items , iterkeys , itervalues , iteritems , __getitem__ , __contains__ ). Additionally there is a resolve() method that doesn’t fail with a KeyError but returns an Undefined object for missing variables.

A dict of read only, global variables the template looks up. These can either come from another Context , from the Environment.globals or Template.globals or points to a dict created by combining the globals with the variables passed to the render function. It must not be altered.

The template local variables. This list contains environment and context functions from the parent scope as well as local modifications and exported variables from the template. The template will modify this dict during template evaluation but filters and context functions are not allowed to modify it.

The environment that loaded the template.

This set contains all the names the template exports. The values for the names are in the vars dict. In order to get a copy of the exported variables as dict, get_exported() can be used.

The load name of the template owning this context.

A dict with the current mapping of blocks in the template. The keys in this dict are the names of the blocks, and the values a list of blocks registered. The last item in each list is the current active block (latest in the inheritance chain).

Call the callable with the arguments and keyword arguments provided but inject the active context or environment as first argument if the callable is a contextfunction() or environmentfunction() .

Return the complete context as dict including the exported variables. For optimizations reasons this might not return an actual copy so be careful with using it.

Get a new dict with the exported variables.

Looks up a variable like __getitem__ or get but returns an Undefined object with the name of the name looked up.

Context is immutable for the same reason Python’s frame locals are immutable inside functions. Both Jinja2 and Python are not using the context / frame locals as data storage for variables but only as primary data source.

When a template accesses a variable the template does not define, Jinja2 looks up the variable in the context, after that the variable is treated as if it was defined in the template.

2.6 Git Basics - Tagging

Like most VCSs, Git has the ability to tag specific points in a repository’s history as being important. Typically, people use this functionality to mark release points ( v1.0 , v2.0 and so on). In this section, you’ll learn how to list existing tags, how to create and delete tags, and what the different types of tags are.

Listing Your Tags

Listing the existing tags in Git is straightforward. Just type git tag (with optional -l or --list ):

This command lists the tags in alphabetical order the order in which they are displayed has no real importance.

You can also search for tags that match a particular pattern. The Git source repo, for instance, contains more than 500 tags. If you’re interested only in looking at the 1.8.5 series, you can run this:

If you want just the entire list of tags, running the command git tag implicitly assumes you want a listing and provides one the use of -l or --list in this case is optional.

If, however, you’re supplying a wildcard pattern to match tag names, the use of -l or --list is mandatory.

Creating Tags

Git supports two types of tags: lightweight and annotated.

A lightweight tag is very much like a branch that doesn’t change — it’s just a pointer to a specific commit.

Annotated tags, however, are stored as full objects in the Git database. They’re checksummed contain the tagger name, email, and date have a tagging message and can be signed and verified with GNU Privacy Guard (GPG). It’s generally recommended that you create annotated tags so you can have all this information but if you want a temporary tag or for some reason don’t want to keep the other information, lightweight tags are available too.

Annotated Tags

Creating an annotated tag in Git is simple. The easiest way is to specify -a when you run the tag command:

The -m specifies a tagging message, which is stored with the tag. If you don’t specify a message for an annotated tag, Git launches your editor so you can type it in.

You can see the tag data along with the commit that was tagged by using the git show command:

That shows the tagger information, the date the commit was tagged, and the annotation message before showing the commit information.

Lightweight Tags

Another way to tag commits is with a lightweight tag. This is basically the commit checksum stored in a file — no other information is kept. To create a lightweight tag, don’t supply any of the -a , -s , or -m options, just provide a tag name:

This time, if you run git show on the tag, you don’t see the extra tag information. The command just shows the commit:

Tagging Later

You can also tag commits after you’ve moved past them. Suppose your commit history looks like this:

Now, suppose you forgot to tag the project at v1.2, which was at the “Update rakefile” commit. You can add it after the fact. To tag that commit, you specify the commit checksum (or part of it) at the end of the command:

You can see that you’ve tagged the commit:

Sharing Tags

By default, the git push command doesn’t transfer tags to remote servers. You will have to explicitly push tags to a shared server after you have created them. This process is just like sharing remote branches — you can run git push origin <tagname> .

If you have a lot of tags that you want to push up at once, you can also use the --tags option to the git push command. This will transfer all of your tags to the remote server that are not already there.

Now, when someone else clones or pulls from your repository, they will get all your tags as well.

git push <remote> --tags will push both lightweight and annotated tags. There is currently no option to push only lightweight tags, but if you use git push <remote> --follow-tags only annotated tags will be pushed to the remote.

Deleting Tags

To delete a tag on your local repository, you can use git tag -d <tagname> . For example, we could remove our lightweight tag above as follows:

Note that this does not remove the tag from any remote servers. There are two common variations for deleting a tag from a remote server.

The first variation is git push <remote> :refs/tags/<tagname> :

The way to interpret the above is to read it as the null value before the colon is being pushed to the remote tag name, effectively deleting it.

The second (and more intuitive) way to delete a remote tag is with:

Checking out Tags

If you want to view the versions of files a tag is pointing to, you can do a git checkout of that tag, although this puts your repository in “detached HEAD” state, which has some ill side effects:

In “detached HEAD” state, if you make changes and then create a commit, the tag will stay the same, but your new commit won’t belong to any branch and will be unreachable, except by the exact commit hash. Thus, if you need to make changes — say you’re fixing a bug on an older version, for instance — you will generally want to create a branch:

If you do this and make a commit, your version2 branch will be slightly different than your v2.0.0 tag since it will move forward with your new changes, so do be careful.

Porting to Python 2.6¶

This section lists previously described changes and other bugfixes that may require changes to your code:

Classes that aren’t supposed to be hashable should set __hash__ = None in their definitions to indicate the fact.

String exceptions have been removed. Attempting to use them raises a TypeError .

The __init__() method of collections.deque now clears any existing contents of the deque before adding elements from the iterable. This change makes the behavior match list.__init__() .

object.__init__() previously accepted arbitrary arguments and keyword arguments, ignoring them. In Python 2.6, this is no longer allowed and will result in a TypeError . This will affect __init__() methods that end up calling the corresponding method on object (perhaps through using super() ). See bpo-1683368 for discussion.

The Decimal constructor now accepts leading and trailing whitespace when passed a string. Previously it would raise an InvalidOperation exception. On the other hand, the create_decimal() method of Context objects now explicitly disallows extra whitespace, raising a ConversionSyntax exception.

Due to an implementation accident, if you passed a file path to the built-in __import__() function, it would actually import the specified file. This was never intended to work, however, and the implementation now explicitly checks for this case and raises an ImportError .

C API: the PyImport_Import() and PyImport_ImportModule() functions now default to absolute imports, not relative imports. This will affect C extensions that import other modules.

C API: extension data types that shouldn’t be hashable should define their tp_hash slot to PyObject_HashNotImplemented() .

The socket module exception socket.error now inherits from IOError . Previously it wasn’t a subclass of StandardError but now it is, through IOError . (Implemented by Gregory P. Smith bpo-1706815.)

The xmlrpclib module no longer automatically converts and datetime.time to the xmlrpclib.DateTime type the conversion semantics were not necessarily correct for all applications. Code using xmlrpclib should convert date and time instances. (bpo-1330538)

(3.0-warning mode) The Exception class now warns when accessed using slicing or index access having Exception behave like a tuple is being phased out.

(3.0-warning mode) inequality comparisons between two dictionaries or two objects that don’t implement comparison methods are reported as warnings. dict1 == dict2 still works, but dict1 < dict2 is being phased out.

Comparisons between cells, which are an implementation detail of Python’s scoping rules, also cause warnings because such comparisons are forbidden entirely in 3.0.