Skip to main content

Keep all your website's pages under one template

Project description

AutoSite

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.

Try it online on repl.it

PyPI

Github

Unofficial guide

Installation

As a package

You can install AutoSite 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.

Embedded

__init__.py can also be run directly like the pre-PyPI AutoSite script. Just paste 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).

Usage

  1. Run autosite. It will create a basic default.html template and the in and 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.
    

    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 "in" 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.

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.

However, conditional text still has some issues. 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 Distribution

AutoSite-1.3.tar.gz (11.4 kB view details)

Uploaded Source

File details

Details for the file AutoSite-1.3.tar.gz.

File metadata

  • Download URL: AutoSite-1.3.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for AutoSite-1.3.tar.gz
Algorithm Hash digest
SHA256 1c62773e1b989a41f106a33975566bafa83ec187c6f56cfc5972baf70092f09b
MD5 31d95863f4b75369c21844b226ba7f9e
BLAKE2b-256 5e1eaedbdf8b12fe09f8b24c5ee86169487cf573bd8e2a9472970f8d804d7050

See more details on using hashes here.

Supported by

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