Skip to main content

Keep all your website's pages under one template

Project description

AutoSite PyPI version

AutoSite helps you keep all of your website's pages in the same basic template. Managing a navigation bar, a footer, and even meta/OpenGraph tags across several pages is simple.

This repository is home to the original AutoSite Python script, updated to functional parity with its .NET-based sibling, AutoSite. AutoSite Legacy is cross-platform and aims to provide an elegant CLI option.

Installation

As a package

You can install AutoSite Legacy as a package. You can cd to the directory where you're building your site and build with the autosite command. It can be installed with the command pip install autosite or pip3 install autosite depending on your configuration.

Hacking on the script and want to install from the current master branch? You can also install with pip3 install ..

As a standalone script

__init__.py can be run directly, without installing the package. Just copy it into wherever you're working and you can run it from there. You'll need to install the requirements manually, which are in the requirements.txt file with the pip install -r requirements.txt or pip3 install -r requirements.txt commands (provided that you downloaded or wrote that file to the same directory).

Basic Usage

  1. Run autosite. It will create a basic default.html template, and the pages, includes folders.

  2. Edit templates/default.html, filling in with these tags:

        [#content#] - The page's content.
        [#path#] - The relative file path from root.
        [#root#] - Use this to point to the site's root folder. Helpful for linking to files in `includes`.
        [#modified#] - The page's last modified date.
    

    You can also use any other attributes, like [#title#] or [#description#], provided that you define them in each page as below.

  3. Add your pages to the "pages" folder. You can define a title and description, or any other attributes you wish, and tell AutoSite which template to use for the page at the top of the file like so:

        <!-- attrib title: Your title -->
        <!-- attrib description: Your description -->
        <!-- attrib template: default -->
        <p>Everything under the above lines will replace [#content#] in template.html.</p>
    

    Put other site files in the "includes" folder. Input pages can be HTML or Markdown files, and use the same attribute syntax.

  4. Run the script. How long it takes depends on how large your site is. Your pages will be in the "out" folder.

Hungry for more? Try these helpful guides on how AutoSite works, contributed by mariteaux:

Customization

Run autosite --help for more options (see below)!

usage: autosite [-h] [-p] [-a] [-q] [-s] [-d DIR] [-m MODIFIED]

options:
-h, --help            show this help message and exit
-p, --prettify        enables BeautifulSoup4 prettifying on output pages (affects whitespace)
-a, --auto            skips user input, for use in scripts etc; non-interactive mode
-q, --quiet           runs silently, skipping user input
-s, --silent          alias for --quiet
-d DIR, --dir DIR     run AutoSite at a specific location
-m MODIFIED, --modified MODIFIED
                        specify date format for the [#modified#] attribute (strftime format; i.e. %Y-%m-%d for 1984-01-19 or %-m/%-d/%Y (*nix) or %#m/%#d/%Y (Windows) for 1/19/1984)

Date format note: This version defaults to YYYY-MM-DD date format. .NET AutoSite uses the system locale as of 1.0, though this behavior may change. The --modified flag allows for a different time format to be used.

Site path note: AutoSite Core uses the site location as a parameter on its own (no flag behind it). This currently isn't the case with Legacy; --dir currently must be used to build a site outside of the current working directory.

Example Command

autosite --auto --modified "%#m/%#d/%Y" --dir "C:\Users\dcb\Desktop\AutoSite.1.0.Gold\SampleSite"

Conditional text

Many sites have a navigation where if you're on a page, that page's name in the navigation is not a link. AutoSite has a feature that lets you replicate this. Consider the following example:

  [path!=index.html]<a href="[#root#]index.html">[/path!=]
      Home
  [path!=index.html]</a>[/path!=]

You can also omit the ! symbol and it will only show if it is that page, like this:

  [path=index.html]<p>[/path=]
      This is the index page.
  [path=index.html]<p>[/path=]

Conditional text is not limited to just file paths! Nearly any attribute can be used with conditional text.

As of 1.4, it is also possible to check for emptiness, like AutoSite (.NET). For example:

  [ready=]This page is not ready (its ready attribute is not set)[/ready=]
  [subtitle!=]<h2>[#subtitle#]</h2>[/subtitle!=]

However, conditional text still has some limitations. You can only have one instance of conditional text per line, it is not nestable, and not multiline either.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

AutoSite-1.4-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file AutoSite-1.4-py3-none-any.whl.

File metadata

  • Download URL: AutoSite-1.4-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for AutoSite-1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bb920b6e3cb53d4fe70471d50b10188b393502d7762f4806e701a0c9763e8d5a
MD5 97674a76c2e4ad51c0fe2358165e1260
BLAKE2b-256 108df980a2b8cc9d39c63efd7821b8223da2026b4dee17426fd6d961fb9d4551

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page